* [PATCH 3/3] Diff overhaul, adding the other half of copy detection.
From: Junio C Hamano @ 2005-05-21 9:42 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vzmuokjhg.fsf@assigned-by-dhcp.cox.net>
This patch extends diff-cache and diff-files to report the
unmodified files to diff-core as well when -C (copy detection)
is in effect, so that the unmodified files can also be used as
the source candidates. The existing test t4003 has been
extended to cover this case.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff-cache.c | 3 ++-
diff-files.c | 2 +-
t/t4003-diff-rename-1.sh | 38 +++++++++++++++++++++++++++++++++++++-
3 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/diff-cache.c b/diff-cache.c
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -71,7 +71,8 @@ static int show_modified(struct cache_en
}
oldmode = old->ce_mode;
- if (mode == oldmode && !memcmp(sha1, old->sha1, 20))
+ if (mode == oldmode && !memcmp(sha1, old->sha1, 20) &&
+ detect_rename < 2)
return 0;
mode = ntohl(mode);
diff --git a/diff-files.c b/diff-files.c
--- a/diff-files.c
+++ b/diff-files.c
@@ -126,7 +126,7 @@ int main(int argc, char **argv)
continue;
}
changed = ce_match_stat(ce, &st);
- if (!changed)
+ if (!changed && detect_rename < 2)
continue;
oldmode = ntohl(ce->ce_mode);
diff --git a/t/t4003-diff-rename-1.sh b/t/t4003-diff-rename-1.sh
--- a/t/t4003-diff-rename-1.sh
+++ b/t/t4003-diff-rename-1.sh
@@ -22,6 +22,10 @@ test_expect_success \
rm -f COPYING &&
git-update-cache --add --remove COPYING COPYING.?'
+# tree has COPYING. work tree has COPYING.1 and COPYING.2,
+# both are slightly edited. So we say you copy-and-edit one,
+# and rename-and-edit the other.
+
GIT_DIFF_OPTS=-u0 git-diff-cache -M $tree |
sed -e 's/\([0-9][0-9]*\)/#/g' >current &&
cat >expected <<\EOF
@@ -58,7 +62,11 @@ test_expect_success \
test_expect_success \
'prepare work tree again' \
'mv COPYING.2 COPYING &&
- git-update-cache --add --remove COPYING COPYING.1'
+ git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
+
+# tree has COPYING. work tree has COPYING and COPYING.1,
+# both are slightly edited. So we say you edited one,
+# and copy-and-edit the other.
GIT_DIFF_OPTS=-u0 git-diff-cache -C $tree |
sed -e 's/\([0-9][0-9]*\)/#/g' >current
@@ -90,4 +98,32 @@ test_expect_success \
'validate output from rename/copy detection' \
'diff -u current expected'
+test_expect_success \
+ 'prepare work tree once again' \
+ 'cat ../../COPYING >COPYING &&
+ git-update-cache --add --remove COPYING COPYING.1'
+
+# tree has COPYING. work tree has the same COPYING and COPYING.1,
+# but COPYING is not edited. We say you copy-and-edit COPYING.1;
+# this is only possible because -C mode now reports the unmodified
+# file to the diff-core.
+
+GIT_DIFF_OPTS=-u0 git-diff-cache -C $tree |
+sed -e 's/\([0-9][0-9]*\)/#/g' >current
+cat >expected <<\EOF
+diff --git a/COPYING b/COPYING.#
+similarity index #%
+copy from COPYING
+copy to COPYING.#
+--- a/COPYING
++++ b/COPYING.#
+@@ -# +# @@
+- HOWEVER, in order to allow a migration to GPLv# if that seems like
++ However, in order to allow a migration to GPLv# if that seems like
+EOF
+
+test_expect_success \
+ 'validate output from rename/copy detection' \
+ 'diff -u current expected'
+
test_done
------------------------------------------------
^ permalink raw reply
* [PATCH] Teach diff-tree to report unmodified paths for -C option.
From: Junio C Hamano @ 2005-05-21 10:11 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vfywgkj90.fsf_-_@assigned-by-dhcp.cox.net>
Linus, I have a bit of design issue that there is no way for the
diff-core layer to affect the behaviour of the caller. It is
not too big a problem with others, but for diff-tree the effect
is prominent.
If you do this:
./git-rev-list HEAD | ./git-diff-tree -Sdiff-tree-helper --stdin -M
you will get many uninteresting headers from git-diff-tree,
until you hit something "interesting". What I want to see in
this case is probably to omit the header and commit information
diff-tree usually gives while "pickaxe" filters everything out
(i.e. nothing interesting to report), and teach diff-tree to do
the header thing only when diff-core says there is something
interesting. So far I haven't found a good way to do this.
Another useless comment. For obvious reasons, there is nothing
we can do about the diff-helper to add "the other half of copy
detection information", because what it can tell diff-core is
limited to its input, which usually is just differences prepared
by somebody else, and it cannot know anything about unchanged
files. When I started pushing '-p' flag to diff-tree family, I
remember that your reaction was neutral to moderately negative
("I'd tolerate, although I think it is redundant and you are not
even generating diff yourself anyway" as opposed to "That's just
great"). I think now you would thank me for shoving the diff
interface into them ;-).
I did not touch diff-tree for full-scale -C option in the last
series, but if you want to have it, it is easy.
This one is untested but it should just work (TM).
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
# - HEAD: Diff overhaul, adding the other half of copy detection.
# + (working tree)
diff --git a/diff-tree.c b/diff-tree.c
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -117,7 +117,7 @@ static int compare_tree_entry(void *tree
show_file("+", tree2, size2, base);
return 1;
}
- if (!memcmp(sha1, sha2, 20) && mode1 == mode2)
+ if (!memcmp(sha1, sha2, 20) && mode1 == mode2 && detect_rename < 2)
return 0;
/*
^ permalink raw reply
* Re: [PATCH] Fix use of wc in t0000-basic
From: Herbert Xu @ 2005-05-21 10:37 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: torvalds, git
In-Reply-To: <Pine.LNX.4.21.0505202045580.30848-100000@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> wrote:
>
> - 'test "$(wc -l full-of-directories | sed -e "s/ .*//")" = 257'
> + 'test $(cat full-of-directories | wc -l) = 257'
You don't need the cat:
wc -l < full-of-directories
will do the same thing.
It's also better to use -eq instead of = since you are comparing
numbers, not strings. If you do that you can keep the double
quotes since the spaces will be removed automatically.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH] Teach diff-tree to report unmodified paths for -C option.
From: Junio C Hamano @ 2005-05-21 10:51 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vpsvkj3bu.fsf_-_@assigned-by-dhcp.cox.net>
>>>>> "JCH" == Junio C Hamano <junkio@cox.net> writes:
JCH> Linus, I have a bit of design issue that...
Another thing I forgot to mention, even in the documentation.
Currently all the diff-tree family says -M and -C imply -p which
is by itself sensible, because rename-edit and copy-edit cannot
be expressed with the diff-raw format (the format only takes one
path).
On the other hand, pickaxe is really a diff filter, so it can
work with both diff-raw and diff-patch format. Here is my
favorite example, in git.pasky aka cogito archive:
./git-rev-list pasky |
./git-diff-tree --stdin -S'static const char *tag_cached = "";
static const char *tag_unmerged = "";
static const char *tag_removed = "";'
.....
ffbe1addd5a5b7b7c2f987625a5aa6c1d22e3705 (from 20d37ef67286e5131d2333d7b4662bc70f9d4937)
20d37ef67286e5131d2333d7b4662bc70f9d4937 (from e78d97723cd77d46d8767a5a27965077249fd080)
*100644->100644 blob 58b5aee94ee76c9201c580d271fcb6aaf20d421f->a2d8cbb2f8d0090a496177cd38f252786d29c3d6 ls-files.c
e78d97723cd77d46d8767a5a27965077249fd080 (from cc167ccaeb1adcdc392f9e03ed1225762ea3cf96)
cc167ccaeb1adcdc392f9e03ed1225762ea3cf96 (from 4df1e7950787197f7cad081b98f9ffe6c4089fc9)
.....
^ permalink raw reply
* Re: [PATCH] Fix use of wc in t0000-basic
From: Junio C Hamano @ 2005-05-21 10:53 UTC (permalink / raw)
To: Herbert Xu; +Cc: Daniel Barkalow, torvalds, git
In-Reply-To: <E1DZRMi-00021X-00@gondolin.me.apana.org.au>
>>>>> "HX" == Herbert Xu <herbert@gondor.apana.org.au> writes:
HX> It's also better to use -eq instead of = since you are comparing
HX> numbers, not strings. If you do that you can keep the double
HX> quotes since the spaces will be removed automatically.
I remember being burned by busybox "test" which did not ignore
spaces. I do not know if the latest one is fixed, though.
^ permalink raw reply
* Re: [PATCH] Fix use of wc in t0000-basic
From: Herbert Xu @ 2005-05-21 11:01 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Daniel Barkalow, torvalds, git
In-Reply-To: <7vhdgwj1ed.fsf@assigned-by-dhcp.cox.net>
On Sat, May 21, 2005 at 03:53:30AM -0700, Junio C Hamano wrote:
> >>>>> "HX" == Herbert Xu <herbert@gondor.apana.org.au> writes:
>
> HX> It's also better to use -eq instead of = since you are comparing
> HX> numbers, not strings. If you do that you can keep the double
> HX> quotes since the spaces will be removed automatically.
>
> I remember being burned by busybox "test" which did not ignore
> spaces. I do not know if the latest one is fixed, though.
Are you sure that it didn't ignore the leading spaces with -eq?
The code in question just calls strtol.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [RFC] git-fsck-cache argument processing
From: Olivier Galibert @ 2005-05-21 15:09 UTC (permalink / raw)
To: Sean; +Cc: git
In-Reply-To: <4870.10.10.10.24.1116646732.squirrel@linux1>
On Fri, May 20, 2005 at 11:38:52PM -0400, Sean wrote:
> -?, --help Give this help list
Could you make that '-h' please ?
> -V, --version Print program version
And that '-v'. -V traditionally means verbose, -v version. Yes, I
know there are counter-examples, but statistically...
OG.
^ permalink raw reply
* Re: [RFC] git-fsck-cache argument processing
From: Jeff Garzik @ 2005-05-21 15:35 UTC (permalink / raw)
To: Olivier Galibert; +Cc: Sean, git
In-Reply-To: <20050521150926.GA96606@dspnet.fr.eu.org>
Olivier Galibert wrote:
> And that '-v'. -V traditionally means verbose, -v version. Yes, I
> know there are counter-examples, but statistically...
In my experience, lowercase 'v' means verbose :)
Jeff
^ permalink raw reply
* Re: gitk-1.0 released
From: Linus Torvalds @ 2005-05-21 16:35 UTC (permalink / raw)
To: jon; +Cc: Kari Hameenaho, git
In-Reply-To: <2cfc40320505202340e5d1aee@mail.gmail.com>
On Sat, 21 May 2005, Jon Seymour wrote:
>
> > - mark everything reachable from OLD_HEAD as being uninteresting (aka
> > "seen"), and everything that reaches OLD_HEAD as being interesting
> > and print it out.
>
> Won't this step end up traversing back to the root anyway?
Sorry, bad wording on my part. Here "reachable" means only withing the
context of "currently parsed", not "globally reachable".
So no, the reachability tests would not traverse anywhere new.
Linus
^ permalink raw reply
* Re: gitweb wishlist
From: Kay Sievers @ 2005-05-21 17:14 UTC (permalink / raw)
To: Matthias Urlichs; +Cc: git
In-Reply-To: <pan.2005.05.21.07.29.14.58375@smurf.noris.de>
On Sat, 2005-05-21 at 09:29 +0200, Matthias Urlichs wrote:
> Hi, Kay Sievers wrote:
>
> > Something like that: :)
>
> Cool.
>
> More feature requests: ;-)
> - Alternate white and almost-white backgrounds in the lists (all of them ;-)
> so that wide-screened people like me don't lose context when their eyes
> travel the long road from left to right edge of the screen. ;-)
Done!
> - Merges currently don't have diff links. It'd be nice to have one for
> each parent.
Done! But I'm not sure if that is really useful. It may create a very
very big diff. :)
> - File diffs have the "diff" link on the *parent*, not on the child.
> That's counter-intuitive -- if I want to see what the Foo patch changes,
> I should be able to click on the "diff" link on _that_ line, not the one
> below it. Example:
> http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=history;h=9636273dae265b9354b861b373cd43cd76a6d0fe;f=MAINTAINERS
No, the "diff" link is a diff against the current commit not an
incremental one from revision to revision. Me may change that, I'm not
sure what's the best here.
Kay
^ permalink raw reply
* Re: [RFC] git-fsck-cache argument processing
From: Sean @ 2005-05-21 17:22 UTC (permalink / raw)
To: Olivier Galibert; +Cc: git
In-Reply-To: <20050521150926.GA96606@dspnet.fr.eu.org>
On Sat, May 21, 2005 11:09 am, Olivier Galibert said:
> On Fri, May 20, 2005 at 11:38:52PM -0400, Sean wrote:
>> -?, --help Give this help list
>
> Could you make that '-h' please ?
>
>> -V, --version Print program version
>
> And that '-v'. -V traditionally means verbose, -v version. Yes, I
> know there are counter-examples, but statistically...
>
Hey Olivier,
Both of these options are generated automatically by argp. I'm sure there
is a way to override them, but i'd rather just leave them as given by
argp. For the first case, if you try '-h' on the command line you get:
$ git-fsck-cache -h
git-fsck-cache: invalid option -- h
Try `git-fsck-cache --help' or `git-fsck-cache --usage' for more information.
So it leads to the proper help message.
Sean
^ permalink raw reply
* Re: [PATCH 3/3] Diff overhaul, adding the other half of copy detection.
From: Linus Torvalds @ 2005-05-21 17:25 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vfywgkj90.fsf_-_@assigned-by-dhcp.cox.net>
On Sat, 21 May 2005, Junio C Hamano wrote:
>
> This patch extends diff-cache and diff-files to report the
> unmodified files to diff-core as well when -C (copy detection)
> is in effect, so that the unmodified files can also be used as
> the source candidates. The existing test t4003 has been
> extended to cover this case.
I love how I can just say "oh, keep in mind that we might want to.." and
24 hours later you did it.
Applied and pushed out, and I enjoyed seeing the output of
git-whatchanged -C
and doing a "/^copy" that shows it figuring out (correctly) that
git-resolve-script was based on git-pull-script. Very cool.
I'm also somewhat surprised by the fact that it even seems to be usable on
the kernel tree:
diff --git a/include/asm-um/archparam-i386.h b/include/asm-um/elf-i386.h
similarity index 89%
copy from include/asm-um/archparam-i386.h
copy to include/asm-um/elf-i386.h
--- a/include/asm-um/archparam-i386.h
+++ b/include/asm-um/elf-i386.h
...
cool.
Linus
^ permalink raw reply
* Re: [PATCH] Fix use of wc in t0000-basic
From: Junio C Hamano @ 2005-05-21 17:24 UTC (permalink / raw)
To: Herbert Xu; +Cc: Daniel Barkalow, torvalds, git
In-Reply-To: <20050521110129.GA7924@gondor.apana.org.au>
>>>>> "HX" == Herbert Xu <herbert@gondor.apana.org.au> writes:
HX> Are you sure that it didn't ignore the leading spaces with -eq?
HX> The code in question just calls strtol.
Sorry, I am not sure whose fault it was, and the recollection
comes from my distant past. It could have been that the
smallish shell in that semi-embedded environment had an
incompatible built-in "test" command which was burning me, but
I distinctively remember changing many of the vendor supplied
shell script that had:
if test " $number" -eq 3
then
...
either stripping dq around it or simply removing the space from
there, depending on how that $number was generated.
Since I assume we are only talking about portability across
POSIXy world I do not think this is a big issue.
^ permalink raw reply
* Re: [PATCH 3/3] Diff overhaul, adding the other half...
From: Junio C Hamano @ 2005-05-21 18:10 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.58.0505211016140.2206@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> I love how I can just say "oh, keep in mind that we might
LT> want to.." and 24 hours later you did it.
Nah, it's more like 40 hours, but yes I am here to serve your
wishes ;-).
LT> I'm also somewhat surprised by the fact that it even seems
LT> to be usable on the kernel tree:
Surprised? Correctness-wise and/or performance-wise?
^ permalink raw reply
* Re: [PATCH 3/3] Diff overhaul, adding the other half...
From: Linus Torvalds @ 2005-05-21 18:27 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vzmuoh2ma.fsf_-_@assigned-by-dhcp.cox.net>
On Sat, 21 May 2005, Junio C Hamano wrote:
>
> LT> I'm also somewhat surprised by the fact that it even seems
> LT> to be usable on the kernel tree:
>
> Surprised? Correctness-wise and/or performance-wise?
Performance-wise. It seems to be quite usable, even doing just a plain
"git-whatchanged -C" on the kernel with no limits on what it does.
Now, all of the actual test-cases I looked at were actually parts of
patches where the source file _had_ been modified, so I didn't see a case
where it selected any of the random 17,000 files that were _not_ modified,
and I didn't double-check further than your commit message saying that it
really does that, so..
Linus
^ permalink raw reply
* Re: [PATCH 3/3] Diff overhaul, adding the other half...
From: Linus Torvalds @ 2005-05-21 18:34 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <Pine.LNX.4.58.0505211124440.2206@ppc970.osdl.org>
On Sat, 21 May 2005, Linus Torvalds wrote:
>
> Now, all of the actual test-cases I looked at were actually parts of
> patches where the source file _had_ been modified, so I didn't see a case
> where it selected any of the random 17,000 files that were _not_ modified,
> and I didn't double-check further than your commit message saying that it
> really does that, so..
Oh, I decided to double-check, and no, it doesn't actually do a full copy
check for diff-tree. Only for diff-cache and diff-files.
Which is a sensible default, and I note that you sent a separate email for
testing the extreme case. I'll try that out too, just for fun,
Linus
^ permalink raw reply
* [PATCH 1/3] - Add GIT Version number
From: Sean @ 2005-05-21 18:32 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 391 bytes --]
Add a version number to the GIT Makefile; lifted from the Linux kernel
source. Once set, the version number will be reported by the "--version"
option on git commands that are converted to argp argument processing.
The version number was arbitrarily set to 0.5.0 as a starting point, but
obviously you can change it as you see fit.
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
[-- Attachment #2: argp-Makefile-v3.patch --]
[-- Type: application/octet-stream, Size: 639 bytes --]
Index: Makefile
===================================================================
--- 58741c69570705801db4b785681790d636475695/Makefile (mode:100644)
+++ uncommitted/Makefile (mode:100644)
@@ -7,8 +7,16 @@
# BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely randomly
# break unless your underlying filesystem supports those sub-second times
# (my ext3 doesn't).
+#
+VERSION = 0
+PATCHLEVEL = 5
+SUBLEVEL = 0
+EXTRAVERSION =
+
+RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+
COPTS=-O2
-CFLAGS=-g $(COPTS) -Wall
+CFLAGS=-g $(COPTS) -Wall '-DVERSION="$(RELEASE)"'
prefix=$(HOME)
bin=$(prefix)/bin
^ permalink raw reply
* [PATCH 2/3] - Convert git-fsck-cache to argp
From: Sean @ 2005-05-21 18:32 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 611 bytes --]
First in a series of patches to convert git commands to use "argp" for
argument processing as suggested by Jeff Garzik. This patch converts
git-fsck-cache. It improves the usage message, adds a --version option,
and allows options to be combined together with a single leading dash.
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Acked-by: "Jeff Garzik" <jgarzik@pobox.com>
Acked-by: "Junio C Hamano" <junkio@cox.net>
Documentation/git-fsck-cache.txt | 6 +++
fsck-cache.c | 60
++++++++++++++++++++++-----------------
2 files changed, 39 insertions(+), 27 deletions(-)
[-- Attachment #2: argp-fsck-cache-v3.patch --]
[-- Type: application/octet-stream, Size: 3267 bytes --]
Index: fsck-cache.c
===================================================================
--- 58741c69570705801db4b785681790d636475695/fsck-cache.c (mode:100644)
+++ uncommitted/fsck-cache.c (mode:100644)
@@ -1,5 +1,7 @@
#include <sys/types.h>
#include <dirent.h>
+#include <argp.h>
+const char *argp_program_version = VERSION;
#include "cache.h"
#include "commit.h"
@@ -407,36 +409,42 @@
find_file_objects(git_dir, "refs");
}
+static const char doc[] = "Perform repository consistency check";
+
+static struct argp_option options[] = {
+ {"unreachable", 'u', 0, 0, "Show missing objects or deltas"},
+ {"tags", 't', 0, 0, "Show revision tags"},
+ {"root", 'r', 0, 0, "Show root objects, ie. those without parents"},
+ {"delta-depth", 'd', 0, 0, "Show the maximum length of delta chains"},
+ {"cache", 'c', 0, 0, "Mark all objects referenced by cache as reachable"},
+ { }
+};
+
+static error_t parse_opt (int key, char *arg, struct argp_state *state)
+{
+ switch (key) {
+ case 'u': show_unreachable = 1; break;
+ case 't': show_tags = 1; break;
+ case 'r': show_root = 1; break;
+ case 'd': show_max_delta_depth = 1; break;
+ case 'c': keep_cache_objects = 1; break;
+ default: return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static const struct argp argp = { options, parse_opt, "[HEAD-SHA1...]", doc };
+
int main(int argc, char **argv)
{
int i, heads;
char *sha1_dir;
+ int idx;
- for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
-
- if (!strcmp(arg, "--unreachable")) {
- show_unreachable = 1;
- continue;
- }
- if (!strcmp(arg, "--tags")) {
- show_tags = 1;
- continue;
- }
- if (!strcmp(arg, "--root")) {
- show_root = 1;
- continue;
- }
- if (!strcmp(arg, "--delta-depth")) {
- show_max_delta_depth = 1;
- continue;
- }
- if (!strcmp(arg, "--cache")) {
- keep_cache_objects = 1;
- continue;
- }
- if (*arg == '-')
- usage("git-fsck-cache [--tags] [[--unreachable] [--cache] <head-sha1>*]");
+ error_t rc = argp_parse(&argp, argc, argv, 0, &idx, NULL);
+ if (rc) {
+ fprintf(stderr, "argument failed: %s\n", strerror(rc));
+ return 1;
}
sha1_dir = get_object_directory();
@@ -450,7 +458,7 @@
expand_deltas();
heads = 0;
- for (i = 1; i < argc; i++) {
+ for (i = idx; i < argc; i++) {
const char *arg = argv[i];
if (*arg == '-')
Index: Documentation/git-fsck-cache.txt
===================================================================
--- 4708925e3e3b955ffcb417fc4acdbb0aafdf8dc0/Documentation/git-fsck-cache.txt (mode:100644)
+++ uncommitted/Documentation/git-fsck-cache.txt (mode:100644)
@@ -9,7 +9,8 @@
SYNOPSIS
--------
-'git-fsck-cache' [--tags] [--root] [[--unreachable] [--cache] <object>\*]
+'git-fsck-cache' [--tags] [--root] [--delta-depth]
+ [[--unreachable] [--cache] <object>\*]
DESCRIPTION
-----------
@@ -34,6 +35,9 @@
Consider any object recorded in the cache also as a head node for
an unreachability trace.
+--delta-depth::
+ Show length of longest delta chain.
+
It tests SHA1 and general object sanity, and it does full tracking of
the resulting reachability and everything else. It prints out any
corruption it finds (missing or bad objects), and if you use the
^ permalink raw reply
* [PATCH 3/3] - Convert git-checkout-cache to argp
From: Sean @ 2005-05-21 18:33 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 587 bytes --]
Use argp to process command line arguments for git-checkout-cache. Also,
fix things up so that the order of options on the command line no longer
matters. To this end, the "-f" (--force) switch only applies to the
individual files given on the command line. A new forcing version of the
"-a" (--all) switch is added as "-A" (--forceall).
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Documentation/git-checkout-cache.txt | 17 +++--
checkout-cache.c | 113
+++++++++++++++++------------------
2 files changed, 68 insertions(+), 62 deletions(-)
[-- Attachment #2: argp-checkout-cache-v3.patch --]
[-- Type: application/octet-stream, Size: 6319 bytes --]
Index: checkout-cache.c
===================================================================
--- 4708925e3e3b955ffcb417fc4acdbb0aafdf8dc0/checkout-cache.c (mode:100644)
+++ uncommitted/checkout-cache.c (mode:100644)
@@ -3,8 +3,6 @@
*
* Copyright (C) 2005 Linus Torvalds
*
- * Careful: order of argument flags does matter. For example,
- *
* git-checkout-cache -a -f file.c
*
* Will first check out all files listed in the cache (but not
@@ -14,7 +12,7 @@
*
* Also, just doing "git-checkout-cache" does nothing. You probably
* meant "git-checkout-cache -a". And if you want to force it, you
- * want "git-checkout-cache -f -a".
+ * want "git-checkout-cache -A".
*
* Intuitiveness is not the goal here. Repeatability is. The
* reason for the "no arguments means no work" thing is that
@@ -25,7 +23,7 @@
* which will force all existing *.h files to be replaced with
* their cached copies. If an empty command line implied "all",
* then this would force-refresh everything in the cache, which
- * was not the point.
+ * was not the point. However, please note the -r option of xargs.
*
* Oh, and the "--" is just a good idea when you know the rest
* will be filenames. Just so that you wouldn't have a filename
@@ -35,8 +33,12 @@
#include <sys/types.h>
#include <dirent.h>
#include "cache.h"
+#include <argp.h>
+const char *argp_program_version = VERSION;
static int force = 0, quiet = 0, not_new = 0, refresh_cache = 0;
+static int force_opt = 0, force_all = 0, all = 0;
+static const char *base_opt = "";
static void create_directories(const char *path)
{
@@ -226,68 +228,67 @@
return 0;
}
+static const char doc[] = "Populate working tree with files from cache";
+
+static struct argp_option options[] = {
+ {"prefix", 1, "base", 0, "Prepend base to each file before checkout"},
+ {"all", 'a', 0, 0, "Checkout entire cache, will NOT overwrite"},
+ {"forceall", 'A', 0, 0, "Checkout entire cache, with overwrite"},
+ {"force", 'f', 0, 0, "Checkout files listed on command line, with overwrite"},
+ {"quiet", 'q', 0, 0, "Suppress warnings"},
+ {"not-new", 'n', 0, 0, "Checkout existing files only"},
+ {"update", 'u', 0, 0, "Update cache with new stat info"},
+ { }
+};
+
+static error_t parse_opt (int key, char *arg, struct argp_state *state)
+{
+ switch (key) {
+ case 'a': all = 1; break;
+ case 'q': quiet = 1; break;
+ case 'n': not_new = 1; break;
+ case 'f': force_opt = 1; break;
+ case 1: base_opt = arg; break;
+ case 'u': refresh_cache = 1; break;
+ case 'A': force_all = 1; all = 1; break;
+ default: return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static const struct argp argp = { options, parse_opt, "[FILES...]", doc };
+
int main(int argc, char **argv)
{
- int i, force_filename = 0;
- const char *base_dir = "";
struct cache_file cache_file;
- int newfd = -1;
+ int i, idx, newfd = -1;
if (read_cache() < 0) {
die("invalid cache");
}
- for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
- if (!force_filename) {
- if (!strcmp(arg, "-a")) {
- checkout_all(base_dir);
- continue;
- }
- if (!strcmp(arg, "--")) {
- force_filename = 1;
- continue;
- }
- if (!strcmp(arg, "-f")) {
- force = 1;
- continue;
- }
- if (!strcmp(arg, "-q")) {
- quiet = 1;
- continue;
- }
- if (!strcmp(arg, "-n")) {
- not_new = 1;
- continue;
- }
- if (!strcmp(arg, "-u")) {
- refresh_cache = 1;
- if (newfd < 0)
- newfd = hold_index_file_for_update
- (&cache_file,
- get_index_file());
- if (newfd < 0)
- die("cannot open index.lock file.");
- continue;
- }
- if (!memcmp(arg, "--prefix=", 9)) {
- base_dir = arg+9;
- continue;
- }
- }
- if (base_dir[0]) {
- /* when --prefix is specified we do not
- * want to update cache.
- */
- if (refresh_cache) {
- close(newfd); newfd = -1;
- rollback_index_file(&cache_file);
- }
- refresh_cache = 0;
- }
- checkout_file(arg, base_dir);
+ error_t rc = argp_parse(&argp, argc, argv, 0, &idx, NULL);
+ if (rc) {
+ fprintf(stderr, "argument failed: %s\n", strerror(rc));
+ return 1;
}
+ if (refresh_cache) {
+ if (base_opt[0])
+ die("cannot update cache when --prefix option is used");
+ newfd = hold_index_file_for_update(&cache_file, get_index_file());
+ if (newfd < 0)
+ die("cannot open index.lock file.");
+ }
+
+ force = force_all;
+ if (all)
+ checkout_all(base_opt);
+
+ force = force_opt;
+ for (i = idx; i < argc; i++)
+ checkout_file(argv[i], base_opt);
+
if (0 <= newfd &&
(write_cache(newfd, active_cache, active_nr) ||
commit_index_file(&cache_file)))
Index: Documentation/git-checkout-cache.txt
===================================================================
--- 4708925e3e3b955ffcb417fc4acdbb0aafdf8dc0/Documentation/git-checkout-cache.txt (mode:100644)
+++ uncommitted/Documentation/git-checkout-cache.txt (mode:100644)
@@ -9,8 +9,8 @@
SYNOPSIS
--------
-'git-checkout-cache' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
- [--] <file>...
+'git-checkout-cache' [-u] [-q] [-a] [-A] [-f] [-n] [--prefix=<string>]
+ [--] [file]...
DESCRIPTION
-----------
@@ -24,15 +24,20 @@
the cache file.
-q::
- be quiet if files exist or are not in the cache
+ be quiet if files exist or are not in the cache.
-f::
- forces overwrite of existing files
+ forces overwrite when checking out files listed on the
+ command line (does not apply to -a option).
-a::
checks out all files in the cache (will then continue to
process listed files).
+-A::
+ checks out all files in the cache, forces overwrite of
+ existing files.
+
-n::
Don't checkout new files, only refresh files already checked
out.
@@ -44,7 +49,7 @@
--::
Do not interpret any more arguments as options.
-Note that the order of the flags matters:
+Example:
git-checkout-cache -a -f file.c
@@ -54,7 +59,7 @@
Also, just doing "git-checkout-cache" does nothing. You probably meant
"git-checkout-cache -a". And if you want to force it, you want
-"git-checkout-cache -f -a".
+"git-checkout-cache -A".
Intuitiveness is not the goal here. Repeatability is. The reason for
the "no arguments means no work" thing is that from scripts you are
^ permalink raw reply
* Re: [PATCH 3/3] Diff overhaul, adding the other half...
From: Linus Torvalds @ 2005-05-21 18:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <Pine.LNX.4.58.0505211128570.2206@ppc970.osdl.org>
On Sat, 21 May 2005, Linus Torvalds wrote:
>
> Which is a sensible default, and I note that you sent a separate email for
> testing the extreme case. I'll try that out too, just for fun,
Hmm.. It's not working well. Not only does it take a lot of CPU time (do
an fsck first to make sure you're not seekign the disk all over the
place), but it "finds" lots of things like this:
diff --git a/drivers/usb/misc/emi62_fw_m.h b/drivers/media/dvb/bt8xx/dst_ca.h
similarity index 99%
copy from drivers/usb/misc/emi62_fw_m.h
copy to drivers/media/dvb/bt8xx/dst_ca.h
--- a/drivers/usb/misc/emi62_fw_m.h
+++ b/drivers/media/dvb/bt8xx/dst_ca.h
@@ -1,8853 +1,58 @@
/*
- * This file is generated from three different files, provided by Emagic.
- */
-/* generated Tue Jun 3 21:36:11 EEST 2003 */
+ CA-driver for TwinHan DST Frontend/Card
which looks quite bogus (it they aren't similar at all, and the diff is
huge).
I think that your similarity check has a tendency to do bad things if one
of the files is huge: in this case we have
torvalds@ppc970:~/v2.6/linux> wc -c drivers/media/dvb/bt8xx/dst_ca.h drivers/usb/misc/emi62_fw_m.h
1591 drivers/media/dvb/bt8xx/dst_ca.h
795679 drivers/usb/misc/emi62_fw_m.h
797270 total
and you consider them "similar", probably because it turns out that
a delta that just removes everything is very small (it's just a "delete
bytes x-y") so you compare that "small" delta to a "large total file" and
you think it's an almost perfect match.
Now, for _renames_ that is actually half-way the right thing to do, but
for copies, you should compare the size not to the _sum_ of the two files,
but to just the size of the file that you generate.
But it's a fun example ;)
Linus
^ permalink raw reply
* Re: [RFC] git-fsck-cache argument processing
From: Olivier Galibert @ 2005-05-21 18:49 UTC (permalink / raw)
To: Sean; +Cc: git
In-Reply-To: <2015.10.10.10.24.1116696150.squirrel@linux1>
On Sat, May 21, 2005 at 01:22:30PM -0400, Sean wrote:
> Both of these options are generated automatically by argp.
I see. Then I'll guess I'll have to put argp in the "crap" pile next
to libtool and automake.
> I'm sure there
> is a way to override them, but i'd rather just leave them as given by
> argp. For the first case, if you try '-h' on the command line you get:
>
> $ git-fsck-cache -h
> git-fsck-cache: invalid option -- h
> Try `git-fsck-cache --help' or `git-fsck-cache --usage' for more information.
>
> So it leads to the proper help message.
How neat. Of course using the right option under (t)csh gives:
galibert@m62:~ #201 >git-fsck-cache -?
git-fsck-cache: No match.
Importing this windowism is beyond stupid.
OG.
^ permalink raw reply
* Re: [RFC] git-fsck-cache argument processing
From: Sean @ 2005-05-21 19:00 UTC (permalink / raw)
To: Olivier Galibert; +Cc: git
In-Reply-To: <20050521184909.GA1729@dspnet.fr.eu.org>
On Sat, May 21, 2005 2:49 pm, Olivier Galibert said:
> On Sat, May 21, 2005 at 01:22:30PM -0400, Sean wrote:
>> Both of these options are generated automatically by argp.
>
> I see. Then I'll guess I'll have to put argp in the "crap" pile next
> to libtool and automake.
Okay now don't go saying things you can't take back <g>.
> How neat. Of course using the right option under (t)csh gives:
>
> galibert@m62:~ #201 >git-fsck-cache -?
> git-fsck-cache: No match.
>
> Importing this windowism is beyond stupid.
Hmmm, that kinda sucks, but the --help should still work fine. I suppose
we could figure out how to use -h instead.
Sean
^ permalink raw reply
* Re: [RFC] git-fsck-cache argument processing
From: Linus Torvalds @ 2005-05-21 19:47 UTC (permalink / raw)
To: Sean; +Cc: git
In-Reply-To: <4870.10.10.10.24.1116646732.squirrel@linux1>
On Fri, 20 May 2005, Sean wrote:
>
> -u, --unreachable Show missing objects or deltas
That's the wrong description.
fsck always shows missing objects, but "--unreachable" makes it also show
objects that cannot be reached from any of the references (either passed
in on the command line, or the implicit references we take if no explicit
reference is given).
So in many ways, "--unreachable" is about the _reverse_ of showing missing
objects: it's about showing _extraneous_ objects that aren't needed by the
ref that was passed in.
Linus
^ permalink raw reply
* Re: [RFC] git-fsck-cache argument processing
From: Linus Torvalds @ 2005-05-21 19:49 UTC (permalink / raw)
To: Sean; +Cc: git
In-Reply-To: <4870.10.10.10.24.1116646732.squirrel@linux1>
Oh, and please fix your mailer. Your attachments show up for me as
unreadable:
[ Part 2, Application/OCTET-STREAM (Name: "fsck-cache-argp-v1.patch") 3.2KB. ]
[ Cannot display this part. Press "V" then "S" to save in a file. ]
ie I'd have to save them to a file to look at them, which is just silly.
So either just add patches in-line (and make sure your mailer doesn't crap
all over whitespace), or add them as text attachments so that people see
the things in their mail readers.
Linus
^ permalink raw reply
* Re: [PATCH 3/3] Diff overhaul, adding the other half...
From: Junio C Hamano @ 2005-05-21 19:54 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.58.0505211124440.2206@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> On Sat, 21 May 2005, Junio C Hamano wrote:
>>
LT> I'm also somewhat surprised by the fact that it even seems
LT> to be usable on the kernel tree:
>>
>> Surprised? Correctness-wise and/or performance-wise?
LT> Performance-wise. It seems to be quite usable, even doing just a plain
LT> "git-whatchanged -C" on the kernel with no limits on what it does.
That is probably because you do not have the feeding of "same"
in diff-tree.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox