Browse Source

always use LF for shell scripts

XhmikosR 6 years ago
parent
commit
3508216d19
3 changed files with 83 additions and 82 deletions
  1. 1
    0
      .gitattributes
  2. 41
    41
      contrib/hash2rev.sh
  3. 41
    41
      contrib/rev2hash.sh

+ 1
- 0
.gitattributes View File

@@ -0,0 +1 @@
1
+*.sh    eol=lf

+ 41
- 41
contrib/hash2rev.sh View File

@@ -1,41 +1,41 @@
1
-#!/bin/bash
2
-# (C) 2013 see Authors.txt
3
-#
4
-# This file is part of MPC-HC.
5
-#
6
-# MPC-HC is free software; you can redistribute it and/or modify
7
-# it under the terms of the GNU General Public License as published by
8
-# the Free Software Foundation; either version 3 of the License, or
9
-# (at your option) any later version.
10
-#
11
-# MPC-HC is distributed in the hope that it will be useful,
12
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
-# GNU General Public License for more details.
15
-#
16
-# You should have received a copy of the GNU General Public License
17
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
-
19
-[[ -n "$1" ]] || exit 1
20
-# This is the last svn changeset, the number and hash can be automatically
21
-# calculated, but it is slow to do that. So it is better to have it hardcoded.
22
-svnrev=5597
23
-svnhash="f669833b77e6515dc5f0a682c5bf665f9a81b2ec"
24
-
25
-#If the git command isn't available or we are not inside a git repo exit the script
26
-git rev-parse --git-dir > /dev/null 2>&1 || exit 1
27
-
28
-# If the input hash is after the switch to git
29
-if [[ $(git merge-base $svnhash "$1") == $(git rev-parse --verify "$svnhash") ]] ; then
30
-  # Count how many changesets we have since the last svn changeset until the input hash
31
-  ver=$(git rev-list --count "$svnhash..$1")
32
-  # Now add it with to last svn revision number
33
-  ver=$((ver+svnrev))
34
-else
35
-  # Get the revision by parsing the git-svn-id
36
-  ver=$(git log -1 --format="%b" "$1")
37
-  ver=${ver#*@}
38
-  ver=${ver%% *}
39
-fi
40
-
41
-echo "$ver"
1
+#!/bin/bash
2
+# (C) 2013 see Authors.txt
3
+#
4
+# This file is part of MPC-HC.
5
+#
6
+# MPC-HC is free software; you can redistribute it and/or modify
7
+# it under the terms of the GNU General Public License as published by
8
+# the Free Software Foundation; either version 3 of the License, or
9
+# (at your option) any later version.
10
+#
11
+# MPC-HC is distributed in the hope that it will be useful,
12
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+# GNU General Public License for more details.
15
+#
16
+# You should have received a copy of the GNU General Public License
17
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+[[ -n "$1" ]] || exit 1
20
+# This is the last svn changeset, the number and hash can be automatically
21
+# calculated, but it is slow to do that. So it is better to have it hardcoded.
22
+svnrev=5597
23
+svnhash="f669833b77e6515dc5f0a682c5bf665f9a81b2ec"
24
+
25
+#If the git command isn't available or we are not inside a git repo exit the script
26
+git rev-parse --git-dir > /dev/null 2>&1 || exit 1
27
+
28
+# If the input hash is after the switch to git
29
+if [[ $(git merge-base $svnhash "$1") == $(git rev-parse --verify "$svnhash") ]] ; then
30
+  # Count how many changesets we have since the last svn changeset until the input hash
31
+  ver=$(git rev-list --count "$svnhash..$1")
32
+  # Now add it with to last svn revision number
33
+  ver=$((ver+svnrev))
34
+else
35
+  # Get the revision by parsing the git-svn-id
36
+  ver=$(git log -1 --format="%b" "$1")
37
+  ver=${ver#*@}
38
+  ver=${ver%% *}
39
+fi
40
+
41
+echo "$ver"

+ 41
- 41
contrib/rev2hash.sh View File

@@ -1,41 +1,41 @@
1
-#!/bin/bash
2
-# (C) 2013 see Authors.txt
3
-#
4
-# This file is part of MPC-HC.
5
-#
6
-# MPC-HC is free software; you can redistribute it and/or modify
7
-# it under the terms of the GNU General Public License as published by
8
-# the Free Software Foundation; either version 3 of the License, or
9
-# (at your option) any later version.
10
-#
11
-# MPC-HC is distributed in the hope that it will be useful,
12
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
-# GNU General Public License for more details.
15
-#
16
-# You should have received a copy of the GNU General Public License
17
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
-
19
-(( $1 > 0 )) || exit
20
-# This is the last svn changeset, the number and hash can be automatically
21
-# calculated, but it is slow to do that. So it is better to have it hardcoded.
22
-svnrev=5597
23
-svnhash="f669833b77e6515dc5f0a682c5bf665f9a81b2ec"
24
-
25
-#If the git command isn't available or we are not inside a git repo exit the script
26
-git rev-parse --git-dir > /dev/null 2>&1 || exit 1
27
-
28
-# If this revision is after the switch to git
29
-if (( $1 > svnrev)); then
30
-  # Calculate how many changesets we need to traverse from the svnrev to HEAD
31
-  n=$(($1 - svnrev))
32
-
33
-  # List the changes from svnhash..HEAD in reverse order and pick the ${n}th
34
-  hash=$(git rev-list --reverse $svnhash..HEAD | sed -n "${n}p")
35
-else
36
-  # Get the hash by parsing the git-svn-id
37
-  # --all is needed in case the given ref is not part of trunk/master but in a tag / svn branch
38
-  hash=$(git log --all -1 --format="%H" --grep="git-svn-id: .*@$1 ")
39
-fi
40
-
41
-echo "$hash"
1
+#!/bin/bash
2
+# (C) 2013 see Authors.txt
3
+#
4
+# This file is part of MPC-HC.
5
+#
6
+# MPC-HC is free software; you can redistribute it and/or modify
7
+# it under the terms of the GNU General Public License as published by
8
+# the Free Software Foundation; either version 3 of the License, or
9
+# (at your option) any later version.
10
+#
11
+# MPC-HC is distributed in the hope that it will be useful,
12
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+# GNU General Public License for more details.
15
+#
16
+# You should have received a copy of the GNU General Public License
17
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+(( $1 > 0 )) || exit
20
+# This is the last svn changeset, the number and hash can be automatically
21
+# calculated, but it is slow to do that. So it is better to have it hardcoded.
22
+svnrev=5597
23
+svnhash="f669833b77e6515dc5f0a682c5bf665f9a81b2ec"
24
+
25
+#If the git command isn't available or we are not inside a git repo exit the script
26
+git rev-parse --git-dir > /dev/null 2>&1 || exit 1
27
+
28
+# If this revision is after the switch to git
29
+if (( $1 > svnrev)); then
30
+  # Calculate how many changesets we need to traverse from the svnrev to HEAD
31
+  n=$(($1 - svnrev))
32
+
33
+  # List the changes from svnhash..HEAD in reverse order and pick the ${n}th
34
+  hash=$(git rev-list --reverse $svnhash..HEAD | sed -n "${n}p")
35
+else
36
+  # Get the hash by parsing the git-svn-id
37
+  # --all is needed in case the given ref is not part of trunk/master but in a tag / svn branch
38
+  hash=$(git log --all -1 --format="%H" --grep="git-svn-id: .*@$1 ")
39
+fi
40
+
41
+echo "$hash"

Loading…
Cancel
Save