From ba8a4970c790c9a03bb3ed72e24d86bd8aa11a67 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 12 Sep 2005 11:23:00 -0700 Subject: [PATCH 01/13] [PATCH] Add note about IANA confirmation The git port (9418) is officially listed by IANA now. So document it. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- cache.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cache.h b/cache.h index dcfcbbc7ce..1d99d6817d 100644 --- a/cache.h +++ b/cache.h @@ -50,6 +50,17 @@ * Your search - "port 9418" - did not match any documents. * * as www.google.com puts it. + * + * This port has been properly assigned for git use by IANA: + * git (Assigned-9418) [I06-050728-0001]. + * + * git 9418/tcp git pack transfer service + * git 9418/udp git pack transfer service + * + * with Linus Torvalds as the point of + * contact. September 2005. + * + * See http://www.iana.org/assignments/port-numbers */ #define DEFAULT_GIT_PORT 9418 From f22cc3fcbfe7755154a3a151215abd39162e2e85 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 12 Sep 2005 12:06:10 -0700 Subject: [PATCH 02/13] [PATCH] Add "git grep" helper Very convenient shorthand for git-ls-files [file-patterns] | xargs grep which I tend to do all the time. Yes, it's trivial, but it's really nice. I can do git grep '\' arch/i386 include/asm-i386 and it does exactly what you'd think it does. And since it just uses the normal git-ls-files file patterns, you can do things like git grep something 'include/*.h' and it will search all header files under the include/ subdirectory. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- Makefile | 2 +- git-grep.sh | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 git-grep.sh diff --git a/Makefile b/Makefile index 5b028b1d94..9c2bdd642b 100644 --- a/Makefile +++ b/Makefile @@ -76,7 +76,7 @@ SCRIPT_SH = \ git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \ git-applymbox.sh git-applypatch.sh \ git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \ - git-merge-resolve.sh + git-merge-resolve.sh git-grep.sh SCRIPT_PERL = \ git-archimport.perl git-cvsimport.perl git-relink.perl \ diff --git a/git-grep.sh b/git-grep.sh new file mode 100755 index 0000000000..db2296c330 --- /dev/null +++ b/git-grep.sh @@ -0,0 +1,20 @@ +#!/bin/sh +flags= +while :; do + pattern="$1" + case "$pattern" in + -i|-I|-a|-E|-H|-h|-l) + flags="$flags $pattern" + shift + ;; + -*) + echo "unknown flag $pattern" >&2 + exit 1 + ;; + *) + break + ;; + esac +done +shift +git-ls-files -z "$@" | xargs -0 grep $flags "$pattern" From 540bf654d007b3289adec37e3008c588ba677e25 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Sep 2005 13:24:55 -0700 Subject: [PATCH 03/13] Allow finding things that begin with a dash in 'git grep' Signed-off-by: Junio C Hamano --- git-grep.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-grep.sh b/git-grep.sh index db2296c330..c77a2d0067 100755 --- a/git-grep.sh +++ b/git-grep.sh @@ -7,6 +7,11 @@ while :; do flags="$flags $pattern" shift ;; + -e) + pattern="$2" + shift + break + ;; -*) echo "unknown flag $pattern" >&2 exit 1 @@ -17,4 +22,4 @@ while :; do esac done shift -git-ls-files -z "$@" | xargs -0 grep $flags "$pattern" +git-ls-files -z "$@" | xargs -0 grep $flags -e "$pattern" From 8ceba720ba5e5e76384e46629e599124c6f36409 Mon Sep 17 00:00:00 2001 From: Fredrik Kuivinen Date: Mon, 12 Sep 2005 23:29:06 +0200 Subject: [PATCH 04/13] [PATCH] Fix assertion failure when merging common ancestors. Bug reported by Junio. Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- git-merge-fredrik.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-merge-fredrik.py b/git-merge-fredrik.py index 920e10ffbf..9a05ab797c 100755 --- a/git-merge-fredrik.py +++ b/git-merge-fredrik.py @@ -60,7 +60,7 @@ def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0): branch1Name, branch2Name, cleanCache, updateWd) - if clean or alwaysWriteTree: + if clean or cleanCache: res = Commit(None, [h1, h2], tree=shaRes) graph.addNode(res) else: From ace36858d3adfde1e497404e831f1cac8034fd4a Mon Sep 17 00:00:00 2001 From: Fredrik Kuivinen Date: Mon, 12 Sep 2005 23:29:54 +0200 Subject: [PATCH 05/13] [PATCH] Exit with status code 2 if we get an exception. Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- git-merge-fredrik.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/git-merge-fredrik.py b/git-merge-fredrik.py index 9a05ab797c..a5ca076021 100755 --- a/git-merge-fredrik.py +++ b/git-merge-fredrik.py @@ -1,6 +1,6 @@ #!/usr/bin/python -import sys, math, random, os, re, signal, tempfile, stat, errno +import sys, math, random, os, re, signal, tempfile, stat, errno, traceback from heapq import heappush, heappop from sets import Set @@ -409,15 +409,20 @@ for nextArg in xrange(1, len(sys.argv)): break print 'Merging', h1, 'with', h2 -h1 = runProgram(['git-rev-parse', '--verify', h1 + '^0']).rstrip() -h2 = runProgram(['git-rev-parse', '--verify', h2 + '^0']).rstrip() -graph = buildGraph([h1, h2]) +try: + h1 = runProgram(['git-rev-parse', '--verify', h1 + '^0']).rstrip() + h2 = runProgram(['git-rev-parse', '--verify', h2 + '^0']).rstrip() -[res, clean] = merge(graph.shaMap[h1], graph.shaMap[h2], - firstBranch, secondBranch, graph) + graph = buildGraph([h1, h2]) -print '' + [res, clean] = merge(graph.shaMap[h1], graph.shaMap[h2], + firstBranch, secondBranch, graph) + + print '' +except: + traceback.print_exc(None, sys.stderr) + sys.exit(2) if clean: sys.exit(0) From 654291a2acb1c28b884cb9376a0d7eb5f8c090b5 Mon Sep 17 00:00:00 2001 From: Fredrik Kuivinen Date: Mon, 12 Sep 2005 23:30:47 +0200 Subject: [PATCH 06/13] [PATCH] Introduce a 'die' function. Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- git-merge-fredrik.py | 15 +++++---------- gitMergeCommon.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/git-merge-fredrik.py b/git-merge-fredrik.py index a5ca076021..e4c6fe3c61 100755 --- a/git-merge-fredrik.py +++ b/git-merge-fredrik.py @@ -120,9 +120,8 @@ def unmergedCacheEntries(): e.stages[stage].mode = mode e.stages[stage].sha1 = sha1 else: - print 'Error: Merge program failed: Unexpected output from', \ - 'git-ls-files:', l - sys.exit(2) + die('Error: Merge program failed: Unexpected output from', \ + 'git-ls-files:', l) return res def mergeTrees(head, merge, common, branch1Name, branch2Name, @@ -381,15 +380,12 @@ def processEntry(entry, branch1Name, branch2Name, files, dirs, os.unlink(src1) os.unlink(src2) else: - print 'ERROR: Fatal merge failure.' - print "ERROR: Shouldn't happen" - sys.exit(2) + die("ERROR: Fatal merge failure, shouldn't happen.") return cleanMerge def usage(): - print 'Usage:', sys.argv[0], ' ... -- ..' - sys.exit(2) + die('Usage:', sys.argv[0], ' ... -- ..') # main entry point as merge strategy module # The first parameters up to -- are merge bases, and the rest are heads. @@ -399,8 +395,7 @@ def usage(): for nextArg in xrange(1, len(sys.argv)): if sys.argv[nextArg] == '--': if len(sys.argv) != nextArg + 3: - print 'Not handling anything other than two heads merge.' - sys.exit(2) + die('Not handling anything other than two heads merge.') try: h1 = firstBranch = sys.argv[nextArg + 1] h2 = secondBranch = sys.argv[nextArg + 2] diff --git a/gitMergeCommon.py b/gitMergeCommon.py index dfa49ff7ec..7e7f317119 100644 --- a/gitMergeCommon.py +++ b/gitMergeCommon.py @@ -10,6 +10,10 @@ if sys.version_info[0] < 2 or \ import subprocess +def die(*args): + printList(args, sys.stderr) + sys.exit(2) + # Debugging machinery # ------------------- @@ -28,11 +32,11 @@ def debug(*args): if funcName in functionsToDebug: printList(args) -def printList(list): +def printList(list, file=sys.stdout): for x in list: - sys.stdout.write(str(x)) - sys.stdout.write(' ') - sys.stdout.write('\n') + file.write(str(x)) + file.write(' ') + file.write('\n') # Program execution # ----------------- From 206e587cb8ab22a9d264c20fb6299124a857281a Mon Sep 17 00:00:00 2001 From: Fredrik Kuivinen Date: Mon, 12 Sep 2005 23:31:22 +0200 Subject: [PATCH 07/13] [PATCH] Make sure we die if we don't get enough arguments. Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- git-merge-fredrik.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-merge-fredrik.py b/git-merge-fredrik.py index e4c6fe3c61..27b84867b0 100755 --- a/git-merge-fredrik.py +++ b/git-merge-fredrik.py @@ -392,6 +392,9 @@ def usage(): # This strategy module figures out merge bases itself, so we only # get heads. +if len(sys.argv) < 4: + usage() + for nextArg in xrange(1, len(sys.argv)): if sys.argv[nextArg] == '--': if len(sys.argv) != nextArg + 3: From 4e48fe3f1c42519f1aad92176489eeb174a319c0 Mon Sep 17 00:00:00 2001 From: Fredrik Kuivinen Date: Mon, 12 Sep 2005 23:31:56 +0200 Subject: [PATCH 08/13] [PATCH] Make the ProgramError class printable. Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- gitMergeCommon.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gitMergeCommon.py b/gitMergeCommon.py index 7e7f317119..ce9694b15e 100644 --- a/gitMergeCommon.py +++ b/gitMergeCommon.py @@ -46,6 +46,9 @@ class ProgramError(Exception): self.progStr = progStr self.error = error + def __str__(self): + return self.progStr + ': ' + self.error + addDebug('runProgram') def runProgram(prog, input=None, returnCode=False, env=None, pipeOutput=True): debug('runProgram prog:', str(prog), 'input:', str(input)) From 5d9d831a51dc7847ad40fac77f9a072aa2d1c0bd Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 12 Sep 2005 16:46:53 -0700 Subject: [PATCH 09/13] Improve "git grep" flags handling This allows any arbitrary flags to "grep", and knows about the few special grep flags that take an argument too. It also allows some flags for git-ls-files, although their usefulness is questionable. With this, something line git grep -w -1 pattern works, without the script enumerating every possible flag. [jc: this is the version Linus sent out after I showed him a barf-o-meter test version that avoids shell arrays. He must have typed this version blindly, since he said: I'm not barfing, but that's probably because my brain just shut down and is desperately trying to gouge my eyes out with a spoon. I slightly fixed it to catch the remaining arguments meant to be given git-ls-files.] Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- git-grep.sh | 64 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/git-grep.sh b/git-grep.sh index c77a2d0067..51924fd7c3 100755 --- a/git-grep.sh +++ b/git-grep.sh @@ -1,25 +1,43 @@ #!/bin/sh -flags= -while :; do - pattern="$1" - case "$pattern" in - -i|-I|-a|-E|-H|-h|-l) - flags="$flags $pattern" - shift - ;; - -e) - pattern="$2" - shift - break - ;; - -*) - echo "unknown flag $pattern" >&2 - exit 1 - ;; - *) - break - ;; - esac +# +# Copyright (c) Linus Torvalds, 2005 +# + +pattern= +flags=() +git_flags=() +while : ; do + case "$1" in + --cached|--deleted|--others|--killed|\ + --ignored|--exclude=*|\ + --exclude-from=*|\--exclude-per-directory=*) + git_flags=("${git_flags[@]}" "$1") + ;; + -e) + pattern="$2" + shift + ;; + -A|-B|-C|-D|-d|-f|-m) + flags=("${flags[@]}" "$1" "$2") + shift + ;; + --) + # The rest are git-ls-files paths (or flags) + shift + break + ;; + -*) + flags=("${flags[@]}" "$1") + ;; + *) + if [ -z "$pattern" ]; then + pattern="$1" + shift + fi + break + ;; + esac + shift done -shift -git-ls-files -z "$@" | xargs -0 grep $flags -e "$pattern" +git-ls-files -z "${git_flags[@]}" "$@" | + xargs -0 grep "${flags[@]}" "$pattern" From 663a5ed5ca964d83269b5616348266bf3b7a7ab4 Mon Sep 17 00:00:00 2001 From: Horst von Brand Date: Sun, 11 Sep 2005 20:00:49 -0400 Subject: [PATCH 10/13] [PATCH] There are several undocumented dependencies There are several undocumented dependencies in the .spec and in the INSTALL files. The following is from Fedora, perhaps other RPM distributions call the packages differently. Also, the manpages aren't always installed gzipped. Updates to git-core.spec.in file: - Some git scripts use Perl - gitk needs wish, which is part of TCL/Tk. - curl is used all over - Need the ssh program from openssh-clients Updates to INSTALL: - Mention wish - Mention ssh Signed-off-by: Horst H. von Brand --- INSTALL | 5 +++++ git-core.spec.in | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index 14580cc471..6e336d7c20 100644 --- a/INSTALL +++ b/INSTALL @@ -64,3 +64,8 @@ Issues of note: You'll only need the merge program if you do development using git, and if you only use git to track other peoples work you'll never notice the lack of it. + + - "wish", the TCL/Tk windowing shell is used in gitk to show the + history graphically + + - "ssh" is used to push and pull over the net diff --git a/git-core.spec.in b/git-core.spec.in index b78a46802a..f98f8db7c7 100644 --- a/git-core.spec.in +++ b/git-core.spec.in @@ -10,7 +10,7 @@ URL: http://kernel.org/pub/software/scm/git/ Source: http://kernel.org/pub/software/scm/git/%{name}-%{version}.tar.gz BuildRequires: zlib-devel, openssl-devel, curl-devel %{!?_without_docs:, xmlto, asciidoc > 6.0.3} BuildRoot: %{_tmppath}/%{name}-%{version}-root -Requires: sh-utils, diffutils, rsync, rcs, python >= 2.4 +Requires: sh-utils, curl, diffutils, rsync, rcs, openssh-clients, perl, python >= 2.4, tk %description This is a stupid (but extremely fast) directory content manager. It @@ -40,10 +40,14 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/git-core/templates/* %doc README COPYING Documentation/*.txt %{!?_without_docs: %doc Documentation/*.html } -%{!?_without_docs: %{_mandir}/man1/*.1.gz} -%{!?_without_docs: %{_mandir}/man7/*.7.gz} +%{!?_without_docs: %{_mandir}/man1/*.1*} +%{!?_without_docs: %{_mandir}/man7/*.7*} %changelog +* Sun Sep 11 2005 Horst H. von Brand +- Updated dependencies +- Don't assume manpages are gzipped + * Sun Aug 07 2005 Horst H. von Brand - Redid the description - Cut overlong make line, loosened changelog a bit From 4a5b63e3e966184aa1ff32770410d485202562ca Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 11 Sep 2005 11:35:20 -0700 Subject: [PATCH 11/13] [PATCH] Omit patches that have already been merged from format-patch output. This switches the logic to pick which commits to include in the output from git-rev-list to git-cherry; as a side effect, 'format-patch ^up mine' would stop working although up..mine would continue to work. Signed-off-by: Junio C Hamano --- git-format-patch.sh | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/git-format-patch.sh b/git-format-patch.sh index cfba1deb25..525a2f2212 100755 --- a/git-format-patch.sh +++ b/git-format-patch.sh @@ -27,8 +27,6 @@ with applymbox. } diff_opts= -IFS=' -' LF=' ' @@ -61,7 +59,10 @@ do --output-directo|--output-director|--output-directory) case "$#" in 1) usage ;; esac; shift outdir="$1" ;; - -*) diff_opts="$diff_opts$LF$1" ;; + -*' '* | -*"$LF"* | -*' '*) + # Ignore diff option that has whitespace for now. + ;; + -*) diff_opts="$diff_opts$1 " ;; *) break ;; esac shift @@ -72,16 +73,20 @@ tt) die '--keep-subject and --numbered are incompatible.' ;; esac -revpair= +rev1= rev2= case "$#" in 2) - revpair="$1..$2" ;; + rev1="$1" rev2="$2" ;; 1) case "$1" in *..*) - revpair="$1";; + rev1=`expr "$1" : '\(.*\)\.\.'` + rev2=`expr "$1" : '.*\.\.\(.*\)'` + ;; *) - revpair="$1..HEAD";; + rev1="$1" + rev2="HEAD" + ;; esac ;; *) usage ;; @@ -127,10 +132,21 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" stripCommitHead='/^'"$_x40"' (from '"$_x40"')$/d' -git-rev-list --no-merges --merge-order \ - $(git-rev-parse --revs-only "$revpair") >$series +git-cherry -v "$rev1" "$rev2" | +while read sign rev comment +do + case "$sign" in + '-') + echo >&2 "Merged already: $comment" + ;; + *) + echo $rev + ;; + esac +done >$series + total=`wc -l <$series | tr -dc "[0-9]"` -i=$total +i=1 while read commit do git-cat-file commit "$commit" | git-stripspace >$commsg @@ -145,7 +161,7 @@ do esac file=`printf '%04d-%stxt' $i "$title"` - i=`expr "$i" - 1` + i=`expr "$i" + 1` echo "* $file" { mailScript=' From 7f88c8463caa14ca397048f8e576e348ce73203a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 11 Sep 2005 14:12:08 -0700 Subject: [PATCH 12/13] [PATCH] Make 'git checkout' a bit more forgiving when switching branches. If you make a commit on a path, and then make the path cache-dirty afterwards without changing its contents, 'git checkout' to switch to another branch is prevented because switching the branches done with 'read-tree -m -u $current $next' detects that the path is cache-dirty, but it does not bother noticing that the contents of the path has not been actualy changed. Since switching branches would involve checking out paths different in the two branches, hence it is reasonably expensive operation, we can afford to run update-index before running read-tree to reduce this kind of false change from triggering the check needlessly. Signed-off-by: Junio C Hamano --- git-checkout.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/git-checkout.sh b/git-checkout.sh index 4e7c57a5f3..4a605cd9c6 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -55,6 +55,7 @@ then git-read-tree --reset $new && git-checkout-index -q -f -u -a else + git-update-index --refresh >/dev/null git-read-tree -m -u $old $new fi From 2aba319a52b3601cff3f32b60bc28023ee45575d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Sep 2005 19:39:15 -0700 Subject: [PATCH 13/13] Document git-grep and link it from the main git(7) page. Also adjust missing description in the git.txt page while we are at it. Signed-off-by: Junio C Hamano --- .gitignore | 1 + Documentation/git-grep.txt | 47 ++++++++++++++++++++++++++++++++++++++ Documentation/git.txt | 9 +++++--- 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 Documentation/git-grep.txt diff --git a/.gitignore b/.gitignore index be9ea5fa9c..cc2b29ebfc 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ git-fetch-pack git-format-patch git-fsck-objects git-get-tar-commit-id +git-grep git-hash-object git-http-fetch git-init-db diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt new file mode 100644 index 0000000000..c275ae26fd --- /dev/null +++ b/Documentation/git-grep.txt @@ -0,0 +1,47 @@ +git-grep(1) +=========== +v0.99.6, Sep 2005 + +NAME +---- +git-grep - print lines matching a pattern + + +SYNOPSIS +-------- +'git-grep'