From 63b398a428c5294819a70d9c56879e7fac62a523 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 28 May 2006 09:23:29 -0700 Subject: [PATCH 01/10] format-patch: -n and -k are mutually exclusive. Signed-off-by: Junio C Hamano --- builtin-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-log.c b/builtin-log.c index cdcf49e21f..db1912a05b 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -203,7 +203,7 @@ int cmd_format_patch(int argc, const char **argv, char **envp) if (start_number < 0) start_number = 1; - if (numbered && keep_subject < 0) + if (numbered && keep_subject) die ("-n and -k are mutually exclusive."); argc = setup_revisions(argc, argv, &rev, "HEAD"); From c928c67d67f73f6bf8c427a187bc92a6d77bc731 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 25 May 2006 22:41:02 -0700 Subject: [PATCH 02/10] t1002: use -U0 instead of --unified=0 Using "-U0" is definitely more portable than using "--unified=0", so we should do that regardless. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- t/t1002-read-tree-m-u-2way.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh index 8335a63e2e..da3c81357b 100755 --- a/t/t1002-read-tree-m-u-2way.sh +++ b/t/t1002-read-tree-m-u-2way.sh @@ -75,7 +75,7 @@ test_expect_success \ git-update-index --add yomin && git-read-tree -m -u $treeH $treeM && git-ls-files --stage >4.out || return 1 - diff --unified=0 M.out 4.out >4diff.out + diff -U0 M.out 4.out >4diff.out compare_change 4diff.out expected && check_cache_at yomin clean && sum bozbar frotz nitfol >actual4.sum && @@ -94,7 +94,7 @@ test_expect_success \ echo yomin yomin >yomin && git-read-tree -m -u $treeH $treeM && git-ls-files --stage >5.out || return 1 - diff --unified=0 M.out 5.out >5diff.out + diff -U0 M.out 5.out >5diff.out compare_change 5diff.out expected && check_cache_at yomin dirty && sum bozbar frotz nitfol >actual5.sum && @@ -112,7 +112,7 @@ test_expect_success \ git-update-index --add frotz && git-read-tree -m -u $treeH $treeM && git-ls-files --stage >6.out && - diff --unified=0 M.out 6.out && + diff -U0 M.out 6.out && check_cache_at frotz clean && sum bozbar frotz nitfol >actual3.sum && cmp M.sum actual3.sum && @@ -129,7 +129,7 @@ test_expect_success \ echo frotz frotz >frotz && git-read-tree -m -u $treeH $treeM && git-ls-files --stage >7.out && - diff --unified=0 M.out 7.out && + diff -U0 M.out 7.out && check_cache_at frotz dirty && sum bozbar frotz nitfol >actual7.sum && if cmp M.sum actual7.sum; then false; else :; fi && @@ -206,7 +206,7 @@ test_expect_success \ git-update-index --add nitfol && git-read-tree -m -u $treeH $treeM && git-ls-files --stage >14.out || return 1 - diff --unified=0 M.out 14.out >14diff.out + diff -U0 M.out 14.out >14diff.out compare_change 14diff.out expected && sum bozbar frotz >actual14.sum && grep -v nitfol M.sum > expected14.sum && @@ -227,7 +227,7 @@ test_expect_success \ echo nitfol nitfol nitfol >nitfol && git-read-tree -m -u $treeH $treeM && git-ls-files --stage >15.out || return 1 - diff --unified=0 M.out 15.out >15diff.out + diff -U0 M.out 15.out >15diff.out compare_change 15diff.out expected && check_cache_at nitfol dirty && sum bozbar frotz >actual15.sum && @@ -264,7 +264,7 @@ test_expect_success \ git-update-index --add bozbar && git-read-tree -m -u $treeH $treeM && git-ls-files --stage >18.out && - diff --unified=0 M.out 18.out && + diff -U0 M.out 18.out && check_cache_at bozbar clean && sum bozbar frotz nitfol >actual18.sum && cmp M.sum actual18.sum' @@ -278,7 +278,7 @@ test_expect_success \ echo gnusto gnusto >bozbar && git-read-tree -m -u $treeH $treeM && git-ls-files --stage >19.out && - diff --unified=0 M.out 19.out && + diff -U0 M.out 19.out && check_cache_at bozbar dirty && sum frotz nitfol >actual19.sum && grep -v bozbar M.sum > expected19.sum && @@ -297,7 +297,7 @@ test_expect_success \ git-update-index --add bozbar && git-read-tree -m -u $treeH $treeM && git-ls-files --stage >20.out && - diff --unified=0 M.out 20.out && + diff -U0 M.out 20.out && check_cache_at bozbar clean && sum bozbar frotz nitfol >actual20.sum && cmp M.sum actual20.sum' @@ -338,7 +338,7 @@ test_expect_success \ git-update-index --add DF && git-read-tree -m -u $treeDF $treeDFDF && git-ls-files --stage >DFDFcheck.out && - diff --unified=0 DFDF.out DFDFcheck.out && + diff -U0 DFDF.out DFDFcheck.out && check_cache_at DF/DF clean' test_done From 508d9e372e0e3cfa55a6224eca5e214364fc66b4 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 27 May 2006 12:24:30 -0700 Subject: [PATCH 03/10] Fix "--abbrev=xyz" for revision listing The revision argument parsing was happily parsing "--abbrev", but it didn't parse "--abbrev=". Which was hidden by the fact that the diff options _would_ parse --abbrev=, so it would actually silently parse it, it just wouldn't use it for the same things that a plain "--abbrev" was used for. Which seems a bit insane. With this patch, if you do "git log --abbrev=10" it will abbreviate the merge parent commit ID's to ten hex characters, which was probably what you expected. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- revision.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/revision.c b/revision.c index 2294b16ea2..42c077a4cb 100644 --- a/revision.c +++ b/revision.c @@ -733,6 +733,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch revs->abbrev = DEFAULT_ABBREV; continue; } + if (!strncmp(arg, "--abbrev=", 9)) { + revs->abbrev = strtoul(arg + 9, NULL, 10); + if (revs->abbrev < MINIMUM_ABBREV) + revs->abbrev = MINIMUM_ABBREV; + else if (revs->abbrev > 40) + revs->abbrev = 40; + continue; + } if (!strcmp(arg, "--abbrev-commit")) { revs->abbrev_commit = 1; continue; From ff4a9ceb971cc9a296bac3a021b945b3c97e4cbe Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Sat, 27 May 2006 18:39:31 +0200 Subject: [PATCH 04/10] Do not call 'cmp' with non-existant -q flag. I cannot find when that flag was removed if it ever existed, I can find nothing about it in the ChangeLog and NEWS file of GNU diff. The current flag is -s aka --quiet aka --silent, so let's use -s, assuming it is a portable flag. Feel free to lart me with a POSIX bible if needed. Signed-off-by: Yann Dirson Signed-off-by: Junio C Hamano --- git-cvsexportcommit.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index f994443c6f..ed87dc9e87 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -151,7 +151,7 @@ my $blob = `git-ls-tree $tree "$f" | cut -f 1 | cut -d ' ' -f 3`; chomp $blob; `git-cat-file blob $blob > $tmpdir/blob`; - if (system('cmp', '-q', $f, "$tmpdir/blob")) { + if (system('cmp', '-s', $f, "$tmpdir/blob")) { warn "Binary file $f in CVS does not match parent.\n"; $dirty = 1; next; From 0d71b31a5e410972e903952cc467a8856b1f13d1 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Sat, 27 May 2006 18:39:33 +0200 Subject: [PATCH 05/10] Document current cvsexportcommit limitations. Since there is no bugtracker that I know of, let's just use the scripts themselves to document their limitations. Signed-off-by: Yann Dirson Signed-off-by: Junio C Hamano --- git-cvsexportcommit.perl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index ed87dc9e87..3e4e90b89b 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -1,5 +1,12 @@ #!/usr/bin/perl -w +# Known limitations: +# - cannot add or remove binary files +# - cannot add parent directories when needed +# - does not propagate permissions +# - tells "ready for commit" even when things could not be completed +# (eg addition of a binary file) + use strict; use Getopt::Std; use File::Temp qw(tempdir); From 3f0f756b839c5f426fcd85c2b5d09164392b8bf6 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Sat, 27 May 2006 18:39:35 +0200 Subject: [PATCH 06/10] Make cvsexportcommit create parent directories as needed. This is a quick port of my initial patch for 1.0.7, that I had forgotten to post. Possibly needs some testing before applying to master. Signed-off-by: Yann Dirson Signed-off-by: Junio C Hamano --- git-cvsexportcommit.perl | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index 3e4e90b89b..57088c3f0b 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -2,7 +2,6 @@ # Known limitations: # - cannot add or remove binary files -# - cannot add parent directories when needed # - does not propagate permissions # - tells "ready for commit" even when things could not be completed # (eg addition of a binary file) @@ -11,7 +10,7 @@ use Getopt::Std; use File::Temp qw(tempdir); use Data::Dumper; -use File::Basename qw(basename); +use File::Basename qw(basename dirname); unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){ die "GIT_DIR is not defined or is unreadable"; @@ -91,7 +90,7 @@ `git-cat-file commit $commit | sed -e '1,/^\$/d' >> .msg`; $? && die "Error extracting the commit message"; -my (@afiles, @dfiles, @mfiles); +my (@afiles, @dfiles, @mfiles, @dirs); my @files = safe_pipe_capture('git-diff-tree', '-r', $parent, $commit); #print @files; $? && die "Error in git-diff-tree"; @@ -99,7 +98,14 @@ chomp $f; my @fields = split(m!\s+!, $f); if ($fields[4] eq 'A') { - push @afiles, $fields[5]; + my $path = $fields[5]; + push @afiles, $path; + # add any needed parent directories + $path = dirname $path; + while (!-d $path and ! grep { $_ eq $path } @dirs) { + unshift @dirs, $path; + $path = dirname $path; + } } if ($fields[4] eq 'M') { push @mfiles, $fields[5]; @@ -114,13 +120,21 @@ # check that the files are clean and up to date according to cvs my $dirty; +foreach my $d (@dirs) { + if (-e $d) { + $dirty = 1; + warn "$d exists and is not a directory!\n"; + } +} foreach my $f (@afiles) { # This should return only one value my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f)); if (@status > 1) { warn 'Strange! cvs status returned more than one line?'}; - unless ($status[0] =~ m/Status: Unknown$/) { + if (-d dirname $f and $status[0] !~ m/Status: Unknown$/ + and $status[0] !~ m/^File: no file /) { $dirty = 1; warn "File $f is already known in your CVS checkout -- perhaps it has been added by another user. Or this may indicate that it exists on a different branch. If this is the case, use -f to force the merge.\n"; + warn "Status was: $status\n"; } } foreach my $f (@mfiles, @dfiles) { @@ -146,6 +160,19 @@ ### +print "Creating new directories\n"; +foreach my $d (@dirs) { + unless (mkdir $d) { + warn "Could not mkdir $d: $!"; + $dirty = 1; + } + `cvs add $d`; + if ($?) { + $dirty = 1; + warn "Failed to cvs add directory $d -- you may need to do it manually"; + } +} + print "'Patching' binary files\n"; my @bfiles = grep(m/^Binary/, safe_pipe_capture('git-diff-tree', '-p', $parent, $commit)); From a57c8bac0021cec21027e25bd797f85b0abf9c81 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 28 May 2006 10:14:38 -0700 Subject: [PATCH 07/10] Let git-clone to pass --template=dir option to git-init-db. Signed-off-by: Junio C Hamano --- Documentation/git-clone.txt | 9 +++++++-- git-clone.sh | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index b333f51045..94d9393372 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -9,8 +9,8 @@ git-clone - Clones a repository SYNOPSIS -------- [verse] -'git-clone' [-l [-s]] [-q] [-n] [--bare] [-o ] [-u ] - [--reference ] +'git-clone' [--template=] [-l [-s]] [-q] [-n] [--bare] + [-o ] [-u ] [--reference ] [] DESCRIPTION @@ -89,6 +89,11 @@ OPTIONS the command to specify non-default path for the command run on the other end. +--template=:: + Specify the directory from which templates will be used; + if unset the templates are taken from the installation + defined default, typically `/usr/share/git-core/templates`. + :: The (possibly remote) repository to clone from. It can be any URL git-fetch supports. diff --git a/git-clone.sh b/git-clone.sh index d96894d4c2..de59904d56 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -9,7 +9,7 @@ unset CDPATH usage() { - echo >&2 "Usage: $0 [--use-separate-remote] [--reference ] [--bare] [-l [-s]] [-q] [-u ] [--origin ] [-n] []" + echo >&2 "Usage: $0 [--template=] [--use-separate-remote] [--reference ] [--bare] [-l [-s]] [-q] [-u ] [--origin ] [-n] []" exit 1 } @@ -102,6 +102,7 @@ quiet= local=no use_local=no local_shared=no +unset template no_checkout= upload_pack= bare= @@ -120,6 +121,11 @@ while *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;; *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) local_shared=yes; use_local=yes ;; + 1,--template) usage ;; + *,--template) + shift; template="--template=$1" ;; + *,--template=*) + template="$1" ;; *,-q|*,--quiet) quiet=-q ;; *,--use-separate-remote) use_separate_remote=t ;; @@ -203,7 +209,7 @@ trap 'err=$?; cd ..; rm -r "$D"; exit $err' 0 case "$bare" in yes) GIT_DIR="$D" ;; *) GIT_DIR="$D/.git" ;; -esac && export GIT_DIR && git-init-db || usage +esac && export GIT_DIR && git-init-db ${template+"$template"} || usage case "$bare" in yes) GIT_DIR="$D" ;; From 034016391c475e98c38a9b715cd670b8b2d0c619 Mon Sep 17 00:00:00 2001 From: "Aneesh Kumar K.V" Date: Sat, 27 May 2006 15:54:14 +0530 Subject: [PATCH 08/10] gitview: Add key binding for F5. Signed-off-by: Junio C Hamano --- contrib/gitview/gitview | 17 +++++++++++++---- contrib/gitview/gitview.txt | 6 ++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview index 781badbc5b..c708534286 100755 --- a/contrib/gitview/gitview +++ b/contrib/gitview/gitview @@ -425,7 +425,7 @@ class DiffWindow: class GitView: """ This is the main class """ - version = "0.7" + version = "0.8" def __init__(self, with_diff=0): self.with_diff = with_diff @@ -449,8 +449,17 @@ class GitView: self.accel_group = gtk.AccelGroup() self.window.add_accel_group(self.accel_group) + self.accel_group.connect_group(0xffc2, 0, gtk.ACCEL_LOCKED, self.refresh); - self.construct() + self.window.add(self.construct()) + + def refresh(self, widget, event=None, *arguments, **keywords): + self.get_encoding() + self.get_bt_sha1() + Commit.children_sha1 = {} + self.set_branch(sys.argv[without_diff:]) + self.window.show() + return True def get_bt_sha1(self): """ Update the bt_sha1 dictionary with the @@ -500,9 +509,9 @@ class GitView: menu_bar.show() vbox.pack_start(menu_bar, expand=False, fill=True) vbox.pack_start(paned, expand=True, fill=True) - self.window.add(vbox) paned.show() vbox.show() + return vbox def construct_top(self): @@ -987,8 +996,8 @@ class GitView: window.set_diff(commit_sha1, parent_sha1, encoding) self.treeview.grab_focus() +without_diff = 0 if __name__ == "__main__": - without_diff = 0 if (len(sys.argv) > 1 ): if (sys.argv[1] == "--without-diff"): diff --git a/contrib/gitview/gitview.txt b/contrib/gitview/gitview.txt index fcf759c307..e3bc4f46c2 100644 --- a/contrib/gitview/gitview.txt +++ b/contrib/gitview/gitview.txt @@ -25,6 +25,9 @@ OPTIONS All the valid option for git-rev-list(1) + Key Bindings: + F5: + To reread references. EXAMPLES ------ @@ -33,6 +36,5 @@ EXAMPLES or drivers/scsi subdirectories gitview --since=2.weeks.ago - Show the changes during the last two weeks + Show the changes during the last two weeks - From 756944350d675bd3c08130df337b776f189ed752 Mon Sep 17 00:00:00 2001 From: "Aneesh Kumar K.V" Date: Sat, 27 May 2006 15:55:32 +0530 Subject: [PATCH 09/10] gitview: Move the console error messages to message dialog Signed-off-by: Junio C Hamano --- contrib/gitview/gitview | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview index c708534286..b836047cf3 100755 --- a/contrib/gitview/gitview +++ b/contrib/gitview/gitview @@ -983,10 +983,15 @@ class GitView: try: self.treeview.set_cursor(self.index[revid]) except KeyError: - print "Revision %s not present in the list" % revid + dialog = gtk.MessageDialog(parent=None, flags=0, + type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_CLOSE, + message_format=None) + dialog.set_markup("Revision %s not present in the list" % revid) # revid == 0 is the parent of the first commit if (revid != 0 ): - print "Try running gitview without any options" + dialog.format_secondary_text("Try running gitview without any options") + dialog.run() + dialog.destroy() self.treeview.grab_focus() From 91b452cba9ff4dd92ded61020179a81d4876efe3 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 28 May 2006 11:37:23 -0700 Subject: [PATCH 10/10] Fix memory leak in "git rev-list --objects" Martin Langhoff points out that "git repack -a" ends up using up a lot of memory for big archives, and that git cvsimport probably should do only incremental repacks in order to avoid having repacking flush all the caches. The big majority of the memory usage of repacking is from git rev-list tracking all objects, and this patch should go a long way in avoiding the excessive memory usage: the bulk of it was due to the object names being leaked from the tree parser. For the historic Linux kernel archive, this simple patch does: Before: /usr/bin/time git-rev-list --all --objects > /dev/null 72.45user 0.82system 1:13.55elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+125376minor)pagefaults 0swaps After: /usr/bin/time git-rev-list --all --objects > /dev/null 75.22user 0.48system 1:16.34elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+43921minor)pagefaults 0swaps where we do end up wasting a bit of time on some extra strdup()s (which could be avoided, but that would require tracking where the pathnames came from), but we avoid a lot of memory usage. Minor page faults track maximum RSS very closely (each page fault maps in one page into memory), so the reduction from 125376 page faults to 43921 means a rough reduction of VM footprint from almost half a gigabyte to about a third of that. Those numbers were also double-checked by looking at "top" while the process was running. (Side note: at least part of the remaining VM footprint is the mapping of the 177MB pack-file, so the remaining memory use is at least partly "well behaved" from a project caching perspective). For the current git archive itself, the memory usage for a "--all --objects" rev-list invocation dropped from 7128 pages to 2318 (27MB to 9MB), so the reduction seems to hold for much smaller projects too. For regular "git-rev-list" usage (ie without the "--objects" flag) this patch has no impact. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- builtin-rev-list.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin-rev-list.c b/builtin-rev-list.c index f11dbd65c1..5277d3cf12 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -103,6 +103,7 @@ static struct object_list **process_blob(struct blob *blob, if (obj->flags & (UNINTERESTING | SEEN)) return p; obj->flags |= SEEN; + name = strdup(name); return add_object(obj, p, path, name); } @@ -122,6 +123,7 @@ static struct object_list **process_tree(struct tree *tree, if (parse_tree(tree) < 0) die("bad tree object %s", sha1_to_hex(obj->sha1)); obj->flags |= SEEN; + name = strdup(name); p = add_object(obj, p, path, name); me.up = path; me.elem = name; @@ -134,6 +136,7 @@ static struct object_list **process_tree(struct tree *tree, p = process_tree(entry->item.tree, p, &me, entry->name); else p = process_blob(entry->item.blob, p, &me, entry->name); + free(entry->name); free(entry); entry = next; }