* Re: git submodule merge madness
From: Sverre Rabbelier @ 2009-01-15 0:32 UTC (permalink / raw)
To: Ask Bjørn Hansen; +Cc: Johannes Schindelin, git
In-Reply-To: <AE1922C4-0543-424B-A635-494445E17E45@develooper.com>
On Thu, Jan 15, 2009 at 00:49, Ask Bjørn Hansen <ask@develooper.com> wrote:
> On Jan 14, 2009, at 2:55 PM, Johannes Schindelin wrote:
>> So.... Which Git version are you are using? Did you test any Git version
>> containing the commit d5a84fb(merge-recursive: fail gracefully with
>> directory/submodule conflicts)?
>
> IIRC I tried 1.6.1 and master as of about a week ago.
>
> I don't see d5a84fb in my repository (and google doesn't find it referenced
> anywhere when I search for "directory/submodule conflicts".
I checked current master:
$ git log --grep="fail gracefully with"
returns nothing. Searching the archive I don't see any reference to
"fail gracefully with" either. I don't see it on your gitweb [0]
either. Did that commit magically dissapear?
[0] http://repo.or.cz/w/git/dscho.git
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: [PATCH replacement for take 3 4/4] color-words: take an optional regular expression describing words
From: Thomas Rast @ 2009-01-15 0:32 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, Santi Béjar, Junio C Hamano, Teemu Likonen
In-Reply-To: <alpine.DEB.1.00.0901142145200.3586@pacific.mpi-cbg.de>
[-- Attachment #1: Type: text/plain, Size: 571 bytes --]
Johannes Schindelin wrote:
> This basically contains the fix I sent earlier.
Unfortunately I found another case where it breaks. It even comes
with a fairly neat test case:
$ g diff --no-index test_a test_b
diff --git 1/test_a 2/test_b
index 289cb9d..2d06f37 100644
--- 1/test_a
+++ 2/test_b
@@ -1 +1 @@
-(:
+(
$ g diff --no-index --color-words='.' test_a test_b
diff --git 1/test_a 2/test_b
index 289cb9d..2d06f37 100644
--- 1/test_a
+++ 2/test_b
@@ -1 +1 @@
:(
--
Thomas Rast
trast@{inf,student}.ethz.ch
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* [RFC PATCH] Make the rebase edit mode really end up in an edit state
From: Anders Melchiorsen @ 2009-01-15 0:27 UTC (permalink / raw)
To: git; +Cc: gitster, Johannes.Schindelin
Previously, the interactive rebase edit mode placed the user after the
commit in question. That was awkward because a commit is supposedly
immutable. Thus, she was forced to use "git commit --amend" for her
changes.
To improve on this UI, we now issue "git reset --soft HEAD^" before
exiting to the user. This puts the changes in the index, editable in
the Git sense. It also makes sure that a pre-filled editor is fired up
when doing "git rebase --continue", in case the user just wanted to
fix the commit message.
The revised UI is close to the situation in a merge/rebase conflict,
and thus familiar to the user.
Signed-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>
---
I always have a hard time figuring out what to do during an
interactive rebase. Recently, it dawned on me that the reason is that
I have to do different things: one thing when editing on purpose, and
a different thing when resolving a conflict. So my fingers never learn.
With this change, I propose to make the UI more uniform. I think that
the new way is more intuitive, too, if you will agree that a Git UI
can be intuitive.
As I expect this to not be acceptable due to compatibility concerns, I
have not tested it much. The patch is mostly to catch some attention,
but I will be happy to complete it if there is interest in the change.
It was surprising for me to find the needed code already present. Now
I know that I do not have to do "git commit --amend", it will happen
automatically if I add some files. That trick alone is worth the time
that I have spent on this :-).
Cheers,
Anders.
Documentation/git-rebase.txt | 10 ++++------
git-rebase--interactive.sh | 29 ++++++++---------------------
2 files changed, 12 insertions(+), 27 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 32f0f12..3442a68 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -320,9 +320,8 @@ not look at them but at the commit names ("deadbee" and "fa1afe1" in this
example), so do not delete or edit the names.
By replacing the command "pick" with the command "edit", you can tell
-'git-rebase' to stop after applying that commit, so that you can edit
-the files and/or the commit message, amend the commit, and continue
-rebasing.
+'git-rebase' to stop after applying that commit. You are free to make
+further modifications before you continue rebasing.
If you want to fold two or more commits into one, replace the command
"pick" with "squash" for the second and subsequent commit. If the
@@ -375,9 +374,8 @@ add other commits. This can be used to split a commit into two:
- Mark the commit you want to split with the action "edit".
-- When it comes to editing that commit, execute `git reset HEAD^`. The
- effect is that the HEAD is rewound by one, and the index follows suit.
- However, the working tree stays the same.
+- When it comes to editing that commit, execute `git reset`. The effect
+ is that the changes in the commit are now only in the working tree.
- Now add the changes to the index that you want to have in the first
commit. You can use `git add` (possibly interactively) or
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index bdec43c..0fe678f 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -274,7 +274,7 @@ peek_next_command () {
do_next () {
rm -f "$DOTEST"/message "$DOTEST"/author-script \
- "$DOTEST"/amend || exit
+ || exit
read command sha1 rest < "$TODO"
case "$command" in
'#'*|'')
@@ -294,13 +294,13 @@ do_next () {
pick_one $sha1 ||
die_with_patch $sha1 "Could not apply $sha1... $rest"
make_patch $sha1
- git rev-parse --verify HEAD > "$DOTEST"/amend
+ git reset --soft HEAD^ ||
+ die "Cannot rewind the HEAD"
warn "Stopped at $sha1... $rest"
- warn "You can amend the commit now, with"
warn
- warn " git commit --amend"
- warn
- warn "Once you are satisfied with your changes, run"
+ warn "You can edit the commit now. When you are satisfied,"
+ warn "mark the corrected paths with 'git add <paths>', and"
+ warn "then run"
warn
warn " git rebase --continue"
warn
@@ -442,22 +442,9 @@ do
else
. "$DOTEST"/author-script ||
die "Cannot find the author identity"
- amend=
- if test -f "$DOTEST"/amend
- then
- amend=$(git rev-parse --verify HEAD)
- test "$amend" = $(cat "$DOTEST"/amend) ||
- die "\
-You have uncommitted changes in your working tree. Please, commit them
-first and then run 'git rebase --continue' again."
- git reset --soft HEAD^ ||
- die "Cannot rewind the HEAD"
- fi
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
- git commit --no-verify -F "$DOTEST"/message -e || {
- test -n "$amend" && git reset --soft $amend
+ git commit --no-verify -F "$DOTEST"/message -e ||
die "Could not commit staged changes."
- }
fi
require_clean_work_tree
@@ -590,7 +577,7 @@ first and then run 'git rebase --continue' again."
#
# Commands:
# p, pick = use commit
-# e, edit = use commit, but stop for amending
+# e, edit = use commit, but stop for editing
# s, squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
--
1.6.0.2.514.g23abd3
^ permalink raw reply related
* Re: [PATCH] git-am: add --directory=<dir> option
From: Junio C Hamano @ 2009-01-15 0:21 UTC (permalink / raw)
To: Stephan Beyer; +Cc: git, Simon 'corecode' Schubert, Kevin Ballard
In-Reply-To: <20090114234602.GD32313@leksak.fem-net>
Stephan Beyer <s-beyer@gmx.net> writes:
> Do I have a thinko or should it be this:
>
> + sed -e 's/'\''/'\''\\\'\'''\''/g' -e 's/.*/ '\''&'\''/'
> ^^
> (added for escaping ' outside single quotes)
Almost.
Certainly my original was bad; shell unquotes to "s/'/'\''/g", but that
backslash is not protected from further interpretation by sed, which
happily turns backslash-single quote into a single quote, which I forgot.
You feed "s/'/'\\\''/g" which correctly protects one backslash from sed by
doubling it, but it has one unnecessary extra backslash. The extra one
does not hurt because the backslash + single quote is eaten by sed to
produce a single quote, but it is not quite right.
We should be feeding sed with "s/'/'\\''/g", so you need to add one
backslash to mine.
> Have you forgotten to add the files prefixed with "am-test-5-" or is this
> patch based on another one?
The one I actually queued is b47dfe9 (git-am: add --directory=<dir>
option, 2009-01-11) and it does include these test vectors. My bad.
This patch is relative to b47dfe9.
-- >8 --
Fix git-am shell quoting
Noticed by Stephan Beyer; the new test is mine.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
git-am.sh | 2 +-
t/t4252-am-options.sh | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git c/git-am.sh w/git-am.sh
index 7e6329b..4beb12d 100755
--- c/git-am.sh
+++ w/git-am.sh
@@ -38,7 +38,7 @@ sq () {
for sqarg
do
printf "%s" "$sqarg" |
- sed -e 's/'\''/'\''\'\'''\''/g' -e 's/.*/ '\''&'\''/'
+ sed -e 's/'\''/'\''\\'\'''\''/g' -e 's/.*/ '\''&'\''/'
done
}
diff --git c/t/t4252-am-options.sh w/t/t4252-am-options.sh
index e91a6da..5fdd188 100755
--- c/t/t4252-am-options.sh
+++ w/t/t4252-am-options.sh
@@ -58,4 +58,12 @@ test_expect_success 'interrupted am --directory="frotz nitfol"' '
grep One "frotz nitfol/file-5"
'
+test_expect_success 'apply to a funny path' '
+ with_sq="with'\''sq"
+ rm -fr .git/rebase-apply &&
+ git reset --hard initial &&
+ git am --directory="$with_sq" "$tm"/am-test-5-2 &&
+ test -f "$with_sq/file-5"
+'
+
test_done
^ permalink raw reply related
* Re: [PATCH v3] parse-opt: migrate builtin-ls-files.
From: Miklos Vajna @ 2009-01-15 0:14 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Pierre Habouzit, git
In-Reply-To: <1231376145-32331-1-git-send-email-vmiklos@frugalware.org>
[-- Attachment #1: Type: text/plain, Size: 289 bytes --]
On Thu, Jan 08, 2009 at 01:55:45AM +0100, Miklos Vajna <vmiklos@frugalware.org> wrote:
> builtin-ls-files.c | 294 ++++++++++++++++++++++++++++------------------------
> 1 files changed, 159 insertions(+), 135 deletions(-)
Hi Junio,
Was this dropped on the floor by accident?
Thanks.
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* [PATCH v2] checkout: implement "-" shortcut name for last branch
From: Thomas Rast @ 2009-01-15 0:12 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
In-Reply-To: <1231977976-8739-1-git-send-email-trast@student.ethz.ch>
Let git-checkout save the old branch as a symref in LAST_HEAD, and
make 'git checkout -' switch back to LAST_HEAD, like 'cd -' does in
the shell.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Bah, sorry. I managed to keep it uncommitted AGAIN.
But this fixed version passes tests. All of them. Really! ;-)
Documentation/git-checkout.txt | 3 ++
Documentation/gitrepository-layout.txt | 4 ++
builtin-checkout.c | 27 ++++++++++++++++-
t/t2012-checkout-last.sh | 50 ++++++++++++++++++++++++++++++++
4 files changed, 83 insertions(+), 1 deletions(-)
create mode 100755 t/t2012-checkout-last.sh
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 9cd5151..1397745 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -133,6 +133,9 @@ the conflicted merge in the specified paths.
+
When this parameter names a non-branch (but still a valid commit object),
your HEAD becomes 'detached'.
++
+You may also specify "`-`", which denotes the last branch you were on
+before the current HEAD.
Detached HEAD
diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index 1befca9..f506c98 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -123,6 +123,10 @@ is often called 'detached HEAD', and almost all commands work
identically as normal. See linkgit:git-checkout[1] for
details.
+LAST_HEAD::
+ A symref that holds the value of HEAD before the last
+ branch switch.
+
branches::
A slightly deprecated way to store shorthands to be used
to specify URL to 'git-fetch', 'git-pull' and 'git-push'
diff --git a/builtin-checkout.c b/builtin-checkout.c
index b5dd9c0..da74831 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -480,6 +480,16 @@ static void report_tracking(struct branch_info *new)
strbuf_release(&sb);
}
+static void save_old_branch(struct branch_info *old, char *msg)
+{
+ if (old->path) {
+ create_symref("LAST_HEAD", old->path, msg);
+ } else if (old->commit) {
+ update_ref(msg, "LAST_HEAD", old->commit->object.sha1, NULL,
+ REF_NODEREF, DIE_ON_ERR);
+ }
+}
+
static void update_refs_for_switch(struct checkout_opts *opts,
struct branch_info *old,
struct branch_info *new)
@@ -505,12 +515,15 @@ static void update_refs_for_switch(struct checkout_opts *opts,
if (old->path && !strcmp(new->path, old->path))
fprintf(stderr, "Already on \"%s\"\n",
new->name);
- else
+ else {
fprintf(stderr, "Switched to%s branch \"%s\"\n",
opts->new_branch ? " a new" : "",
new->name);
+ save_old_branch(old, msg.buf);
+ }
}
} else if (strcmp(new->name, "HEAD")) {
+ save_old_branch(old, msg.buf);
update_ref(msg.buf, "HEAD", new->commit->object.sha1, NULL,
REF_NODEREF, DIE_ON_ERR);
if (!opts->quiet) {
@@ -533,6 +546,8 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
int flag;
memset(&old, 0, sizeof(old));
old.path = resolve_ref("HEAD", rev, 0, &flag);
+ if (old.path)
+ old.path = strdup(old.path);
old.commit = lookup_commit_reference_gently(rev, 1);
if (!(flag & REF_ISSYMREF))
old.path = NULL;
@@ -604,6 +619,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
OPT_END(),
};
int has_dash_dash;
+ int flag;
memset(&opts, 0, sizeof(opts));
memset(&new, 0, sizeof(new));
@@ -671,6 +687,15 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
arg = argv[0];
has_dash_dash = (argc > 1) && !strcmp(argv[1], "--");
+ if (!strcmp(arg, "-")) {
+ arg = resolve_ref("LAST_HEAD", rev, 0, &flag);
+ if (!arg)
+ die("No last branch saved.");
+ if(!prefixcmp(arg, "refs/heads/"))
+ arg += 11;
+ arg = strdup(arg);
+ }
+
if (get_sha1(arg, rev)) {
if (has_dash_dash) /* case (1) */
die("invalid reference: %s", arg);
diff --git a/t/t2012-checkout-last.sh b/t/t2012-checkout-last.sh
new file mode 100755
index 0000000..320f6eb
--- /dev/null
+++ b/t/t2012-checkout-last.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+test_description='checkout can switch to last branch'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo hello >world &&
+ git add world &&
+ git commit -m initial &&
+ git branch other &&
+ echo "hello again" >>world &&
+ git add world &&
+ git commit -m second
+'
+
+test_expect_success '"checkout -" does not work initially' '
+ test_must_fail git checkout -
+'
+
+test_expect_success 'first branch switch' '
+ git checkout other
+'
+
+test_expect_success '"checkout -" switches back' '
+ git checkout - &&
+ test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
+'
+
+test_expect_success '"checkout -" switches forth' '
+ git checkout - &&
+ test "z$(git symbolic-ref HEAD)" = "zrefs/heads/other"
+'
+
+test_expect_success 'detach HEAD' '
+ git checkout $(git rev-parse HEAD)
+'
+
+test_expect_success '"checkout -" attaches again' '
+ git checkout - &&
+ test "z$(git symbolic-ref HEAD)" = "zrefs/heads/other"
+'
+
+test_expect_success '"checkout -" detaches again' '
+ git checkout - &&
+ test "z$(git rev-parse HEAD)" = "z$(git rev-parse other)" &&
+ test_must_fail git symbolic-ref HEAD
+'
+
+test_done
--
1.6.1.282.gae4091.dirty
^ permalink raw reply related
* [PATCH] checkout: implement "-" shortcut name for last branch
From: Thomas Rast @ 2009-01-15 0:06 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Let git-checkout save the old branch as a symref in LAST_HEAD, and
make 'git checkout -' switch back to LAST_HEAD, like 'cd -' does in
the shell.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
I really wished I had this earlier today. I'm just not sure if it's a
good idea, or even possible, to reserve the '-'. I can't seem to
check out a branch '-foo' with git-checkout, but it's easy to create
one with 'git branch -- -foo'. git-check-ref-format(1) doesn't forbid
it either, although the actual 'git check-ref-format -foo' exits with
status 1.
Documentation/git-checkout.txt | 3 +++
Documentation/gitrepository-layout.txt | 4 ++++
builtin-checkout.c | 26 +++++++++++++++++++++++++-
3 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 9cd5151..1397745 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -133,6 +133,9 @@ the conflicted merge in the specified paths.
+
When this parameter names a non-branch (but still a valid commit object),
your HEAD becomes 'detached'.
++
+You may also specify "`-`", which denotes the last branch you were on
+before the current HEAD.
Detached HEAD
diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index 1befca9..f506c98 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -123,6 +123,10 @@ is often called 'detached HEAD', and almost all commands work
identically as normal. See linkgit:git-checkout[1] for
details.
+LAST_HEAD::
+ A symref that holds the value of HEAD before the last
+ branch switch.
+
branches::
A slightly deprecated way to store shorthands to be used
to specify URL to 'git-fetch', 'git-pull' and 'git-push'
diff --git a/builtin-checkout.c b/builtin-checkout.c
index b5dd9c0..356ad6c 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -480,6 +480,15 @@ static void report_tracking(struct branch_info *new)
strbuf_release(&sb);
}
+static void save_old_branch(struct branch_info *old, char *msg)
+{
+ if (old->path) {
+ create_symref("LAST_HEAD", old->path, msg);
+ } else
+ update_ref(msg, "LAST_HEAD", old->commit->object.sha1, NULL,
+ REF_NODEREF, DIE_ON_ERR);
+}
+
static void update_refs_for_switch(struct checkout_opts *opts,
struct branch_info *old,
struct branch_info *new)
@@ -505,12 +514,15 @@ static void update_refs_for_switch(struct checkout_opts *opts,
if (old->path && !strcmp(new->path, old->path))
fprintf(stderr, "Already on \"%s\"\n",
new->name);
- else
+ else {
fprintf(stderr, "Switched to%s branch \"%s\"\n",
opts->new_branch ? " a new" : "",
new->name);
+ save_old_branch(old, msg.buf);
+ }
}
} else if (strcmp(new->name, "HEAD")) {
+ save_old_branch(old, msg.buf);
update_ref(msg.buf, "HEAD", new->commit->object.sha1, NULL,
REF_NODEREF, DIE_ON_ERR);
if (!opts->quiet) {
@@ -533,6 +545,8 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
int flag;
memset(&old, 0, sizeof(old));
old.path = resolve_ref("HEAD", rev, 0, &flag);
+ if (old.path)
+ old.path = strdup(old.path);
old.commit = lookup_commit_reference_gently(rev, 1);
if (!(flag & REF_ISSYMREF))
old.path = NULL;
@@ -604,6 +618,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
OPT_END(),
};
int has_dash_dash;
+ int flag;
memset(&opts, 0, sizeof(opts));
memset(&new, 0, sizeof(new));
@@ -671,6 +686,15 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
arg = argv[0];
has_dash_dash = (argc > 1) && !strcmp(argv[1], "--");
+ if (!strcmp(arg, "-")) {
+ arg = resolve_ref("LAST_HEAD", rev, 0, &flag);
+ if (!arg)
+ die("No last branch saved.");
+ if(!prefixcmp(arg, "refs/heads/"))
+ arg += 11;
+ arg = strdup(arg);
+ }
+
if (get_sha1(arg, rev)) {
if (has_dash_dash) /* case (1) */
die("invalid reference: %s", arg);
--
1.6.1.282.gae4091.dirty
^ permalink raw reply related
* Re: [ANNOUNCE] tig-0.13
From: Jonas Fonseca @ 2009-01-14 23:56 UTC (permalink / raw)
To: git
In-Reply-To: <20090114232456.GA6937@b2j>
bill lam <cbill.lam@gmail.com> wrote Thu, Jan 15, 2009:
> On Wed, 14 Jan 2009, Jonas Fonseca wrote:
> > Tig is an ncurses-based text-mode interface for git. It functions mainly
>
> The Makefile does not link to the unicode version ncursesw, does it
> still work for wide characters?
Yes, it works. You can either create a file called config.make with a
line saying:
LDLIBS = -lncursesw
or use the configure file. If you are not using the tarball generate it
with:
make configure
--
Jonas Fonseca
^ permalink raw reply
* Re: git submodule merge madness
From: Ask Bjørn Hansen @ 2009-01-14 23:49 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <alpine.DEB.1.00.0901142354120.3586@pacific.mpi-cbg.de>
On Jan 14, 2009, at 2:55 PM, Johannes Schindelin wrote:
>> We've (again) replaced a few directories with submodules. Man, it's
>> madness!
>>
>> The typical problem is that we get an error trying to merge a "pre-
>> submodule"
>> branch into master:
>>
>> fatal: cannot read object 894c77319a18c4d48119c2985a9275c9f5883584
>> 'some/sub/dir': It is a submodule!
>> Mark Levedahl wrote an example in July, but I don't think he got
>> any replies:
>> http://marc.info/?l=git&m=121587851313303
>
> So.... Which Git version are you are using? Did you test any Git
> version
> containing the commit d5a84fb(merge-recursive: fail gracefully with
> directory/submodule conflicts)?
IIRC I tried 1.6.1 and master as of about a week ago.
I don't see d5a84fb in my repository (and google doesn't find it
referenced anywhere when I search for "directory/submodule conflicts".
- ask
--
http://develooper.com/ - http://askask.com/
^ permalink raw reply
* Re: [PATCH] git-am: add --directory=<dir> option
From: Stephan Beyer @ 2009-01-14 23:46 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Simon 'corecode' Schubert, Kevin Ballard
In-Reply-To: <7vbpudjanf.fsf@gitster.siamese.dyndns.org>
Hi Junio,
Junio C Hamano wrote:
>
> git-am.sh | 17 +++++++++++++----
> t/t4252-am-options.sh | 8 ++++++++
> 2 files changed, 21 insertions(+), 4 deletions(-)
I think this is missing some
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index b9c6fac..64c8178 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -66,6 +66,7 @@ default. You could use `--no-utf8` to override this.
-C<n>::
-p<n>::
+--directory=<root>::
These flags are passed to the 'git-apply' (see linkgit:git-apply[1])
program that applies
the patch.
or even
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index b9c6fac..327bc3d 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -59,13 +59,10 @@ default. You could use `--no-utf8` to override this.
it is supposed to apply to, and we have those blobs
available locally.
---whitespace=<option>::
- This flag is passed to the 'git-apply' (see linkgit:git-apply[1])
- program that applies
- the patch.
-
-C<n>::
-p<n>::
+--directory=<root>::
+--whitespace=<option>::
These flags are passed to the 'git-apply' (see linkgit:git-apply[1])
program that applies
the patch.
> diff --git c/git-am.sh w/git-am.sh
> index 4b157fe..7e6329b 100755
> --- c/git-am.sh
> +++ w/git-am.sh
[...]
> @@ -33,6 +34,14 @@ cd_to_toplevel
> git var GIT_COMMITTER_IDENT >/dev/null ||
> die "You need to set your committer info first"
>
> +sq () {
> + for sqarg
> + do
> + printf "%s" "$sqarg" |
> + sed -e 's/'\''/'\''\'\'''\''/g' -e 's/.*/ '\''&'\''/'
^^^
$ echo "/fo'ba" | sed -e 's/'\''/'\''\'\'''\''/g' -e 's/.*/ '\''&'\''/'
'/fo'''ba'
Do I have a thinko or should it be this:
+ sed -e 's/'\''/'\''\\\'\'''\''/g' -e 's/.*/ '\''&'\''/'
^^
(added for escaping ' outside single quotes)
leading to:
$ echo "/fo'ba" | sed -e 's/'\''/'\''\\\'\'''\''/g' -e 's/.*/ '\''&'\''/'
'/fo'\''ba'
Well, I was unsure, so I've tested...
Without this change:
$ ./git-am.sh --directory="fo'ba" /tmp/test/*
Applying: abcdefg
./git-am.sh: eval: line 471: unexpected EOF while looking for matching
`''
./git-am.sh: eval: line 472: syntax error: unexpected end of file
Patch failed at 0001.
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".
And with this change:
$ ./git-am.sh --directory="fo'ba" /tmp/test/*
Applying: abcdefg
Applying: asdgasfh
> diff --git c/t/t4252-am-options.sh w/t/t4252-am-options.sh
> index 3ab9e8e..e91a6da 100755
> --- c/t/t4252-am-options.sh
> +++ w/t/t4252-am-options.sh
> @@ -50,4 +50,12 @@ test_expect_success 'interrupted am -C1 -p2' '
> grep "^Three$" file-2
> '
>
> +test_expect_success 'interrupted am --directory="frotz nitfol"' '
> + rm -rf .git/rebase-apply &&
> + git reset --hard initial &&
> + test_must_fail git am --directory="frotz nitfol" "$tm"/am-test-5-? &&
Have you forgotten to add the files prefixed with "am-test-5-" or is this
patch based on another one?
$ git ls-files t/t4252
t/t4252/am-test-1-1
t/t4252/am-test-1-2
t/t4252/am-test-2-1
t/t4252/am-test-2-2
t/t4252/am-test-3-1
t/t4252/am-test-3-2
t/t4252/am-test-4-1
t/t4252/am-test-4-2
t/t4252/file-1-0
t/t4252/file-2-0
Thanks and regards,
Stephan
--------------- proposed interdiff without am-test-5* ---------------
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index b9c6fac..327bc3d 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -59,13 +59,10 @@ default. You could use `--no-utf8` to override this.
it is supposed to apply to, and we have those blobs
available locally.
---whitespace=<option>::
- This flag is passed to the 'git-apply' (see linkgit:git-apply[1])
- program that applies
- the patch.
-
-C<n>::
-p<n>::
+--directory=<root>::
+--whitespace=<option>::
These flags are passed to the 'git-apply' (see linkgit:git-apply[1])
program that applies
the patch.
diff --git a/git-am.sh b/git-am.sh
index 7e6329b..ca3dbcd 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -38,7 +38,7 @@ sq () {
for sqarg
do
printf "%s" "$sqarg" |
- sed -e 's/'\''/'\''\'\'''\''/g' -e 's/.*/ '\''&'\''/'
+ sed -e 's/'\''/'\''\\\'\'''\''/g' -e 's/.*/ '\''&'\''/'
done
}
--
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
^ permalink raw reply related
* Re: [ANNOUNCE] tig-0.13
From: bill lam @ 2009-01-14 23:24 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: git
In-Reply-To: <20090113233643.GA28898@diku.dk>
On Wed, 14 Jan 2009, Jonas Fonseca wrote:
> Tig is an ncurses-based text-mode interface for git. It functions mainly
The Makefile does not link to the unicode version ncursesw, does it
still work for wide characters?
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩264 王昌齡 芙蓉樓送辛漸
寒雨連江夜入吳 平明送客楚山孤 洛陽親友如相問 一片冰心在玉壺
^ permalink raw reply
* Re: jgit merge question
From: Shawn O. Pearce @ 2009-01-14 23:12 UTC (permalink / raw)
To: David Birchfield; +Cc: git
In-Reply-To: <AB447EEF7BAAB7489B29A4F3F788D02C01CDD792@EX07.asurite.ad.asu.edu>
David Birchfield <dbirchfield@asu.edu> wrote:
> Great - thanks so much for this feedback and link. My merge
> needs are straightforward, so hopefully this will suit the need!
>
> I have pulled the latest jgit updates and downloaded the four
> .java files that are referenced in your link. I have added these
> to the directory structure for jgit in the following new folder:
> org.spearce.jgit/src/org/spearce/jgit/merge/
Instead of copying 4 files, why don't you actually fetch the 8
commits and merge them into your local repository? You are getting
build errors because you didn't get an exception type in the errors
directory, and at least two existing classes had new methods added
to them in order to support the merge API.
--
Shawn.
^ permalink raw reply
* Re: 1.5.6.5 fails to clone git.kernel.org/[...]/rostedt/linux-2.6-rt
From: Johannes Schindelin @ 2009-01-14 23:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Tim Shepard, git, Daniel Barkalow
In-Reply-To: <7vpriw26uo.fsf@gitster.siamese.dyndns.org>
Hi,
On Fri, 9 Jan 2009, Junio C Hamano wrote:
> I think we lost the alternate object store support when git-fetch was
> rewritten from the original shell script (that did support fetching from
> such a repository over rsync:// transport) to a reimplementation in C,
> with commit b888d61 (Make fetch a builtin, 2007-09-10).
>
> Later, cd547b4 (fetch/push: readd rsync support, 2007-10-01) attempted to
> resurrect some rsync support (b888d61 lost rsync support completely for
> git-fetch), but introduced these lines in transport.c:
>
> /* NEEDSWORK: handle one level of alternates */
> result = run_command(&rsync);
Indeed... And I know who's responsible for those lines.
However, I am swamped with work these days, and my Git time budget was
_way_ overspent what with the recent patches.
So whoever would like to give it a go, go wild.
This is actually a very fine opportunity for people to get involved who
always wanted to; it is a relatively low-hanging fruit.
It should just be a matter of getting objects/info/alternates (one can
easily reuse a large part of the args[] array filled before the quoted
code) into a temporary file.
If that does not succeed, return 0, otherwise fetch those objects, too
(again reusing most of the args[] array).
It is that easy because objects as well as packs are immutable, so we can
just build the union of objects/packs from the remote and its alternate.
Then all which is left to do is to add a test case to t/t5510-fetch.sh,
and you're set.
As there are already test cases for rsync:// in it, it should be as simple
as putting an empty file into a newly created directory, create an
alternate for the "remote" pointing to the directory, fetching, and
testing that the empty file was copied.
That's possible because rsync:// is dumb and does not verify the files it
copied.
Oh, and don't forget to remove the NEEDSWORK comment :-)
And now I'm curious who's up for it...
Ciao,
Dscho
^ permalink raw reply
* [StGit PATCH] Add --file option to pick
From: Catalin Marinas @ 2009-01-14 22:59 UTC (permalink / raw)
To: git, Karl Hasselström
This allows folding of specific files only.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
---
stgit/commands/pick.py | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/stgit/commands/pick.py b/stgit/commands/pick.py
index ee08c01..b0e9114 100644
--- a/stgit/commands/pick.py
+++ b/stgit/commands/pick.py
@@ -52,6 +52,8 @@ options = [
short = 'Fold the commit object into the current patch'),
opt('--update', action = 'store_true',
short = 'Like fold but only update the current patch files'),
+ opt('-f', '--files', action = 'append',
+ short = 'Only fold the given files'),
opt('--unapplied', action = 'store_true',
short = 'Keep the patch unapplied')]
@@ -83,8 +85,11 @@ def __pick_commit(commit_id, patchname, options):
out.start('Folding commit %s' % commit_id)
# try a direct git apply first
- if not git.apply_diff(bottom, top):
- git.merge_recursive(bottom, git.get_head(), top)
+ if not git.apply_diff(bottom, top, files = options.files):
+ if options.files:
+ raise CmdException, 'Patch folding failed'
+ else:
+ git.merge_recursive(bottom, git.get_head(), top)
out.done()
elif options.update:
@@ -152,6 +157,9 @@ def func(parser, options, args):
if not args:
parser.error('incorrect number of arguments')
+ if options.files and not options.fold:
+ parser.error('--file can only be specified with --fold')
+
if not options.unapplied:
check_local_changes()
check_conflicts()
^ permalink raw reply related
* RE: jgit merge question
From: David Birchfield @ 2009-01-14 22:03 UTC (permalink / raw)
To: git
In-Reply-To: <20090114153034.GZ10179@spearce.org>
Great - thanks so much for this feedback and link. My merge needs are straightforward, so hopefully this will suit the need!
I have pulled the latest jgit updates and downloaded the four .java files that are referenced in your link. I have added these to the directory structure for jgit in the following new folder: org.spearce.jgit/src/org/spearce/jgit/merge/
However, when I try to now make_jgit.sh I am getting a series of errors (pasted below) that appear to stem from not having the same underlying files. Is it possible that I am not getting the most recent jgit release files? Or am I misunderstanding how you expect these Merge files to be used?
Thanks again,
David
<errors>
Entering org.spearce.jgit ...
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:45: cannot find symbol
symbol : class UnmergedPathException
location: package org.spearce.jgit.errors
import org.spearce.jgit.errors.UnmergedPathException;
^
./org/spearce/jgit/merge/Merger.java:184: cannot find symbol
symbol : constructor CanonicalTreeParser(<nulltype>,org.spearce.jgit.lib.Repository,org.spearce.jgit.revwalk.RevTree,org.spearce.jgit.lib.WindowCursor)
location: class org.spearce.jgit.treewalk.CanonicalTreeParser
return new CanonicalTreeParser(null, db, base.getTree(), curs);
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:98: cannot find symbol
symbol : method newInCore()
location: class org.spearce.jgit.dircache.DirCache
cache = DirCache.newInCore();
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:123: cannot find symbol
symbol : variable STAGE_0
location: class org.spearce.jgit.dircache.DirCacheEntry
add(T_THEIRS, DirCacheEntry.STAGE_0);
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:125: cannot find symbol
symbol : variable STAGE_0
location: class org.spearce.jgit.dircache.DirCacheEntry
add(T_OURS, DirCacheEntry.STAGE_0);
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:137: cannot find symbol
symbol : method writeTree(org.spearce.jgit.lib.ObjectWriter)
location: class org.spearce.jgit.dircache.DirCache
resultTree = cache.writeTree(getObjectWriter());
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:139: cannot find symbol
symbol : class UnmergedPathException
location: class org.spearce.jgit.merge.StrategySimpleTwoWayInCore.InCoreMerger
} catch (UnmergedPathException upe) {
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:147: cannot find symbol
symbol : method getRawPath()
location: class org.spearce.jgit.treewalk.NameConflictTreeWalk
builder.addTree(tw.getRawPath(), db, tw.getObjectId(1));
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:149: cannot find symbol
symbol : variable STAGE_0
location: class org.spearce.jgit.dircache.DirCacheEntry
add(T_OURS, DirCacheEntry.STAGE_0);
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:153: cannot find symbol
symbol : variable STAGE_1
location: class org.spearce.jgit.dircache.DirCacheEntry
add(T_BASE, DirCacheEntry.STAGE_1);
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:154: cannot find symbol
symbol : variable STAGE_2
location: class org.spearce.jgit.dircache.DirCacheEntry
add(T_OURS, DirCacheEntry.STAGE_2);
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:155: cannot find symbol
symbol : variable STAGE_3
location: class org.spearce.jgit.dircache.DirCacheEntry
add(T_THEIRS, DirCacheEntry.STAGE_3);
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:163: cannot find symbol
symbol : method getRawPath()
location: class org.spearce.jgit.treewalk.NameConflictTreeWalk
e = new DirCacheEntry(tw.getRawPath(), stage);
^
./org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java:163: internal error; cannot instantiate org.spearce.jgit.dircache.DirCacheEntry.<init> at org.spearce.jgit.dircache.DirCacheEntry to ()
e = new DirCacheEntry(tw.getRawPath(), stage);
^
</errors
-----Original Message-----
David is probably talking about the 8 patch series I proposed to add a
crude merge API to JGit. The patches are available here, based on the
current JGit master:
http://android.git.kernel.org/?p=tools/egit.git;a=shortlog;h=refs/heads/for-gerrit2
git://android.git.kernel.org/tools/egit.git for-gerrit2
^ permalink raw reply
* [StGit PATCH] Check for local changes with "goto"
From: Catalin Marinas @ 2009-01-14 22:59 UTC (permalink / raw)
To: git, Karl Hasselström
This is done by default, unless the --keep option is passed, for
consistency with the "pop" command.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
---
stgit/commands/common.py | 7 +++++++
stgit/commands/goto.py | 8 +++++++-
t/t2300-refresh-subdir.sh | 2 +-
t/t2800-goto-subdir.sh | 4 ++--
t/t3000-dirty-merge.sh | 2 +-
5 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/stgit/commands/common.py b/stgit/commands/common.py
index 6bb3685..8ae43ff 100644
--- a/stgit/commands/common.py
+++ b/stgit/commands/common.py
@@ -100,6 +100,13 @@ def check_conflicts():
' then use "resolve <files>" or revert the'
' changes with "status --reset".')
+def check_clean(repository):
+ """Check whether the index is up to date.
+ """
+ if not repository.default_index.is_clean():
+ raise CmdException('Repository not clean. Use "refresh" or '
+ '"status --reset"')
+
def print_crt_patch(crt_series, branch = None):
if not branch:
patch = crt_series.get_current()
diff --git a/stgit/commands/goto.py b/stgit/commands/goto.py
index 60a917e..6483011 100644
--- a/stgit/commands/goto.py
+++ b/stgit/commands/goto.py
@@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from stgit.commands import common
from stgit.lib import transaction
from stgit import argparse
+from stgit.argparse import opt
help = 'Push or pop patches to the given one'
kind = 'stack'
@@ -27,7 +28,10 @@ Push/pop patches to/from the stack until the one given on the command
line becomes current."""
args = [argparse.other_applied_patches, argparse.unapplied_patches]
-options = []
+options = [
+ opt('-k', '--keep', action = 'store_true',
+ short = 'Keep the local changes')
+]
directory = common.DirectoryHasRepositoryLib()
@@ -38,6 +42,8 @@ def func(parser, options, args):
stack = directory.repository.current_stack
iw = stack.repository.default_iw
+ if not options.keep:
+ common.check_clean(directory.repository)
trans = transaction.StackTransaction(stack, 'goto')
if patch in trans.applied:
to_pop = set(trans.applied[trans.applied.index(patch)+1:])
diff --git a/t/t2300-refresh-subdir.sh b/t/t2300-refresh-subdir.sh
index d731a11..89c95db 100755
--- a/t/t2300-refresh-subdir.sh
+++ b/t/t2300-refresh-subdir.sh
@@ -65,7 +65,7 @@ test_expect_success 'refresh -u -p <subdir>' '
test_expect_success 'refresh an unapplied patch' '
stg refresh -u &&
- stg goto p0 &&
+ stg goto --keep p0 &&
test "$(stg status)" = "M foo.txt" &&
stg refresh -p p1 &&
test "$(stg status)" = "" &&
diff --git a/t/t2800-goto-subdir.sh b/t/t2800-goto-subdir.sh
index 28b8292..855972b 100755
--- a/t/t2800-goto-subdir.sh
+++ b/t/t2800-goto-subdir.sh
@@ -25,7 +25,7 @@ cat > expected2.txt <<EOF
bar
EOF
test_expect_success 'Goto in subdirectory (just pop)' '
- (cd foo && stg goto p1) &&
+ (cd foo && stg goto --keep p1) &&
cat foo/bar > actual.txt &&
test_cmp expected1.txt actual.txt &&
ls foo > actual.txt &&
@@ -48,7 +48,7 @@ cat > expected2.txt <<EOF
bar
EOF
test_expect_success 'Goto in subdirectory (conflicting push)' '
- (cd foo && stg goto p3) ;
+ (cd foo && stg goto --keep p3) ;
[ $? -eq 3 ] &&
cat foo/bar > actual.txt &&
test_cmp expected1.txt actual.txt &&
diff --git a/t/t3000-dirty-merge.sh b/t/t3000-dirty-merge.sh
index f0f79d5..419d86e 100755
--- a/t/t3000-dirty-merge.sh
+++ b/t/t3000-dirty-merge.sh
@@ -26,7 +26,7 @@ test_expect_success 'Push with dirty worktree' '
echo 4 > a &&
[ "$(echo $(stg series --applied --noprefix))" = "p1" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "p2" ] &&
- conflict stg goto p2 &&
+ conflict stg goto --keep p2 &&
[ "$(echo $(stg series --applied --noprefix))" = "p1" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "p2" ] &&
[ "$(echo $(cat a))" = "4" ]
^ permalink raw reply related
* Re: git submodule merge madness
From: Johannes Schindelin @ 2009-01-14 22:55 UTC (permalink / raw)
To: Ask Bjørn Hansen; +Cc: git
In-Reply-To: <ADC7A3B1-6756-4258-93CD-DB40C7D2793C@develooper.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 662 bytes --]
Hi,
On Fri, 9 Jan 2009, Ask Bjørn Hansen wrote:
> We've (again) replaced a few directories with submodules. Man, it's
> madness!
>
> The typical problem is that we get an error trying to merge a "pre-submodule"
> branch into master:
>
> fatal: cannot read object 894c77319a18c4d48119c2985a9275c9f5883584
> 'some/sub/dir': It is a submodule!
> Mark Levedahl wrote an example in July, but I don't think he got any replies:
> http://marc.info/?l=git&m=121587851313303
So.... Which Git version are you are using? Did you test any Git version
containing the commit d5a84fb(merge-recursive: fail gracefully with
directory/submodule conflicts)?
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH 1/4] color-words: fix quoting in t4034
From: Johannes Schindelin @ 2009-01-14 22:41 UTC (permalink / raw)
To: Thomas Rast; +Cc: git, Santi Béjar, Junio C Hamano
In-Reply-To: <3ff3ccf6e3c1cd6a002d200aee5df88a197a7bf6.1231971446.git.trast@student.ethz.ch>
Hi,
On Wed, 14 Jan 2009, Thomas Rast wrote:
> Since the single quotes match the ones used to quote the test text
> itself, they'd be dropped. Use double quotes instead.
See, I suck with quoting.
> ---
>
> I'd squash this into Dscho's 4/4, so no SoB.
Sure, done.
Thanks,
Dscho
^ permalink raw reply
* Re: Compiler requirements for git?
From: Miklos Vajna @ 2009-01-14 22:38 UTC (permalink / raw)
To: Corey Stup; +Cc: git
In-Reply-To: <128172e70901141032p6e830a85i344d72e1b3bb3a89@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
On Wed, Jan 14, 2009 at 01:32:56PM -0500, Corey Stup <coreystup@gmail.com> wrote:
> When trying to compile with a C89 compliant compiler, I'm coming
> across a couple issues:
> - "inline" use
AFAIK that can be avoided with -Dinline=.
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: [PATCH take 3 0/4] color-words improvements
From: Thomas Rast @ 2009-01-14 22:37 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, git, Santi Béjar
In-Reply-To: <alpine.DEB.1.00.0901142203190.3586@pacific.mpi-cbg.de>
[-- Attachment #1: Type: text/plain, Size: 905 bytes --]
Johannes Schindelin wrote:
> > Ack on the new regex semantics, though I'd have implemented it via dying
> > on '\n' instead of silently splitting there (and restarting a new
> > match!).
>
> Hmm. I'd rather not die() in the middle of it.
>
> Maybe we can even handle newlines correctly by replacing them with NULs
> which libxdiff handles just fine?
I'm not sure it's worth the effort---anyone who wants words to stick
together across newlines probably doesn't put a newline there in the
first place, don't they? (And it just shifts the problem to another
special character.)
> Phew. I was almost convinced you would hate me for my criticiscm.
Let's say I wasn't too happy when you asked for two rounds of
improvements and _then_ rejected. But the end result certainly turned
out better, so the criticism was justified.
--
Thomas Rast
trast@{inf,student}.ethz.ch
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: cygwin git diff crash
From: Johannes Schindelin @ 2009-01-14 22:33 UTC (permalink / raw)
To: Jeremy Ramer; +Cc: Git Mailing List
In-Reply-To: <b9fd99020901141409w1e0c926fkc762f8709bd1c13f@mail.gmail.com>
Hi,
On Wed, 14 Jan 2009, Jeremy Ramer wrote:
> Ok this is a weird issue and it's probably cygwin's fault, but I
> haven't found any way to fix it so I' thought I would throw it out
> here for comment.
>
> I am using git 1.6.0.4 on cygwin. I have a repo where if any file has
> changes and git detects as mode 100644 I get this error:
> $git diff
> 3 [main] git 2744 C:\cygwin\bin\git.exe: *** fatal error - could
> not load user32, Win32 error
>
> If I change the mode to 100755 git diff will work fine.
> $chmod a+x test.cpp
> $git diff
> diff --git a/test.cpp b/test.cpp
> old mode 100644
> new mode 100755
> index 7c0dfcd..20987a7
> --- a/test.cpp
> +++ b/test.cpp
> @@ -6,9 +6,11 @@ int main()
>
> void func()
> {
> + int a;^M
> }
>
> void func2()
> {
> + int b;^M
> }
>
> Anybody have a clue as to why this might occur? I have seen this in
> many of the repo's I use, but it is not repeatable. I tried making a
> test repo but could not reproduce.
Wow, that _is_ weird. Does your test suite pass?
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH 3/3] implement pattern matching in ce_path_match
From: Junio C Hamano @ 2009-01-14 22:27 UTC (permalink / raw)
To: Clemens Buchacher; +Cc: git, johannes
In-Reply-To: <20090114192341.GA26703@localhost>
Clemens Buchacher <drizzd@aon.at> writes:
> I think we could at least add an option to disable globbing. Then we can
> also disable the above check conditioned on that. If we allowed globbing
> pattern for following renames wouldn't that result in following the first
> file (or last in history) to match the pattern, which is potentially
> confusing?
Yeah, I agree that would be a reasonable thing to do.
In places we read paths from the index or from the work tree and add them
as pathspec elements---you would want to mark them as non-globbing, too.
Which probably means that "is it Ok to glob this" setting has to be per
pathspec array elements.
^ permalink raw reply
* [PATCH 4/4] color-words: make regex configurable via attributes
From: Thomas Rast @ 2009-01-14 22:26 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Santi Béjar, Junio C Hamano
In-Reply-To: <alpine.DEB.1.00.0901142104400.3586@pacific.mpi-cbg.de>
Make the --color-words splitting regular expression configurable via
the diff driver's 'wordregex' attribute. The user can then set the
driver on a file in .gitattributes. If a regex is given on the
command line, it overrides the driver's setting.
We also provide built-in regexes for the languages that already had
funcname patterns, and add an appropriate diff driver entry for C/++.
(The patterns are designed to run UTF-8 sequences into a single chunk
to make sure they remain readable.)
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Incorporates the last round of Dscho's suggestions.
Documentation/diff-options.txt | 4 ++
Documentation/gitattributes.txt | 21 ++++++++++
diff.c | 10 +++++
t/t4034-diff-words.sh | 49 ++++++++++++++++++++++--
userdiff.c | 78 +++++++++++++++++++++++++++++++-------
userdiff.h | 1 +
6 files changed, 144 insertions(+), 19 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 8689a92..1edb82e 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -102,6 +102,10 @@ differences. You may want to append `|[^[:space:]]` to your regular
expression to make sure that it matches all non-whitespace characters.
A match that contains a newline is silently truncated(!) at the
newline.
++
+The regex can also be set via a diff driver, see
+linkgit:gitattributes[1]; giving it explicitly overrides any diff
+driver setting.
--no-renames::
Turn off rename detection, even when the configuration
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 8af22ec..17707ba 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -317,6 +317,8 @@ patterns are available:
- `bibtex` suitable for files with BibTeX coded references.
+- `cpp` suitable for source code in the C and C++ languages.
+
- `html` suitable for HTML/XHTML documents.
- `java` suitable for source code in the Java language.
@@ -334,6 +336,25 @@ patterns are available:
- `tex` suitable for source code for LaTeX documents.
+Customizing word diff
+^^^^^^^^^^^^^^^^^^^^^
+
+You can customize the rules that `git diff --color-words` uses to
+split words in a line, by specifying an appropriate regular expression
+in the "diff.*.wordregex" configuration variable. For example, in TeX
+a backslash followed by a sequence of letters forms a command, but
+several such commands can be run together without intervening
+whitespace. To separate them, use a regular expression such as
+
+------------------------
+[diff "tex"]
+ wordregex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"
+------------------------
+
+A built-in pattern is provided for all languages listed in the last
+section.
+
+
Performing text diffs of binary files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/diff.c b/diff.c
index 3f07ac1..0e82e18 100644
--- a/diff.c
+++ b/diff.c
@@ -1372,6 +1372,12 @@ int diff_filespec_is_binary(struct diff_filespec *one)
return one->driver->funcname.pattern ? &one->driver->funcname : NULL;
}
+static const char *userdiff_word_regex(struct diff_filespec *one)
+{
+ diff_filespec_load_driver(one);
+ return one->driver->word_regex;
+}
+
void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b)
{
if (!options->a_prefix)
@@ -1532,6 +1538,10 @@ static void builtin_diff(const char *name_a,
ecbdata.diff_words =
xcalloc(1, sizeof(struct diff_words_data));
ecbdata.diff_words->file = o->file;
+ if (!o->word_regex)
+ o->word_regex = userdiff_word_regex(one);
+ if (!o->word_regex)
+ o->word_regex = userdiff_word_regex(two);
if (o->word_regex) {
ecbdata.diff_words->word_regex = (regex_t *)
xmalloc(sizeof(regex_t));
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 6ad1c1f..631ca44 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -22,8 +22,10 @@ decrypt_color () {
word_diff () {
test_must_fail git diff --no-index "$@" pre post > output &&
- decrypt_color < output > output.decrypted &&
- test_cmp expect output.decrypted
+ decrypt_color < output > output.decrypted
+}
+word_diff_check () {
+ test_cmp "$1" output.decrypted
}
cat > pre <<\EOF
@@ -80,7 +82,45 @@ EOF
test_expect_success 'word diff with a regular expression' '
- word_diff --color-words="[a-z]+"
+ word_diff --color-words="[a-z]+" &&
+ word_diff_check expect
+
+'
+
+cat > expect-by-chars <<\EOF
+<WHITE>diff --git a/pre b/post<RESET>
+<WHITE>index 330b04f..5ed8eff 100644<RESET>
+<WHITE>--- a/pre<RESET>
+<WHITE>+++ b/post<RESET>
+<BROWN>@@ -1,3 +1,7 @@<RESET>
+h(4)<GREEN>,hh[44]<RESET>
+<RESET>
+a = b + c<RESET>
+
+<GREEN>aa = a<RESET>
+
+<GREEN>aeff = aeff * ( aaa )<RESET>
+EOF
+
+test_expect_success 'set a diff driver' '
+ git config diff.testdriver.wordregex "[^[:space:]]" &&
+ cat <<EOF > .gitattributes
+pre diff=testdriver
+post diff=testdriver
+EOF
+'
+
+test_expect_success 'use default supplied by driver' '
+
+ word_diff --color-words &&
+ word_diff_check expect-by-chars
+
+'
+
+test_expect_success 'option overrides default' '
+
+ word_diff --color-words="[a-z]+" &&
+ word_diff_check expect
'
@@ -98,7 +138,8 @@ EOF
test_expect_success "test parsing words for newline" '
- word_diff --color-words="a+"
+ word_diff --color-words="a+" &&
+ word_diff_check expect
'
diff --git a/userdiff.c b/userdiff.c
index 3681062..dbfda6d 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -6,14 +6,20 @@
static int ndrivers;
static int drivers_alloc;
-#define FUNCNAME(name, pattern) \
- { name, NULL, -1, { pattern, REG_EXTENDED } }
+#define PATTERNS(name, pattern, wordregex) \
+ { name, NULL, -1, { pattern, REG_EXTENDED }, wordregex }
static struct userdiff_driver builtin_drivers[] = {
-FUNCNAME("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$"),
-FUNCNAME("java",
+PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
+ "[^<>= \t]+|[^[:space:]]|[\x80-\xff]+"),
+PATTERNS("java",
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
- "^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$"),
-FUNCNAME("objc",
+ "^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$",
+ "[a-zA-Z_][a-zA-Z0-9_]*"
+ "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
+ "|[-+*/<>%&^|=!]="
+ "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"
+ "|[^[:space:]]|[\x80-\xff]+"),
+PATTERNS("objc",
/* Negate C statements that can look like functions */
"!^[ \t]*(do|for|if|else|return|switch|while)\n"
/* Objective-C methods */
@@ -21,20 +27,60 @@
/* C functions */
"^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$\n"
/* Objective-C class/protocol definitions */
- "^(@(implementation|interface|protocol)[ \t].*)$"),
-FUNCNAME("pascal",
+ "^(@(implementation|interface|protocol)[ \t].*)$",
+ /* -- */
+ "[a-zA-Z_][a-zA-Z0-9_]*"
+ "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
+ "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"
+ "|[^[:space:]]|[\x80-\xff]+"),
+PATTERNS("pascal",
"^((procedure|function|constructor|destructor|interface|"
"implementation|initialization|finalization)[ \t]*.*)$"
"\n"
- "^(.*=[ \t]*(class|record).*)$"),
-FUNCNAME("php", "^[\t ]*((function|class).*)"),
-FUNCNAME("python", "^[ \t]*((class|def)[ \t].*)$"),
-FUNCNAME("ruby", "^[ \t]*((class|module|def)[ \t].*)$"),
-FUNCNAME("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$"),
-FUNCNAME("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$"),
+ "^(.*=[ \t]*(class|record).*)$",
+ /* -- */
+ "[a-zA-Z_][a-zA-Z0-9_]*"
+ "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
+ "|<>|<=|>=|:=|\\.\\."
+ "|[^[:space:]]|[\x80-\xff]+"),
+PATTERNS("php", "^[\t ]*((function|class).*)",
+ /* -- */
+ "[a-zA-Z_][a-zA-Z0-9_]*"
+ "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
+ "|[-+*/<>%&^|=!.]=|--|\\+\\+|<<=?|>>=?|===|&&|\\|\\||::|->"
+ "|[^[:space:]]|[\x80-\xff]+"),
+PATTERNS("python", "^[ \t]*((class|def)[ \t].*)$",
+ /* -- */
+ "[a-zA-Z_][a-zA-Z0-9_]*"
+ "|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?"
+ "|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\*\\*=?"
+ "|[^[:space:]|[\x80-\xff]+"),
+ /* -- */
+PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$",
+ /* -- */
+ "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*"
+ "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?."
+ "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"
+ "|[^[:space:]|[\x80-\xff]+"),
+PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$",
+ "[={}\"]|[^={}\" \t]+"),
+PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
+ "\\\\[a-zA-Z@]+|[{}]|\\\\.|[^\\{} \t]+"),
+PATTERNS("cpp",
+ /* Jump targets or access declarations */
+ "!^[ \t]*[A-Za-z_][A-Za-z_0-9]*:.*$\n"
+ /* C functions at top level */
+ "^([A-Za-z_][A-Za-z_0-9]*([ \t]+[A-Za-z_][A-Za-z_0-9]*){1,}[ \t]*\\([^;]*)$\n"
+ /* compound type at top level */
+ "^((struct|class|enum)[^;]*)$",
+ /* -- */
+ "[a-zA-Z_][a-zA-Z0-9_]*"
+ "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
+ "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"
+ "|[^[:space:]]|[\x80-\xff]+"),
{ "default", NULL, -1, { NULL, 0 } },
};
-#undef FUNCNAME
+#undef PATTERNS
static struct userdiff_driver driver_true = {
"diff=true",
@@ -134,6 +180,8 @@ int userdiff_config(const char *k, const char *v)
return parse_string(&drv->external, k, v);
if ((drv = parse_driver(k, v, "textconv")))
return parse_string(&drv->textconv, k, v);
+ if ((drv = parse_driver(k, v, "wordregex")))
+ return parse_string(&drv->word_regex, k, v);
return 0;
}
diff --git a/userdiff.h b/userdiff.h
index ba29457..c315159 100644
--- a/userdiff.h
+++ b/userdiff.h
@@ -11,6 +11,7 @@ struct userdiff_driver {
const char *external;
int binary;
struct userdiff_funcname funcname;
+ const char *word_regex;
const char *textconv;
};
--
1.6.1.142.ge070e
^ permalink raw reply related
* [PATCH 3/4] color-words: expand docs with precise semantics
From: Thomas Rast @ 2009-01-14 22:26 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Santi Béjar, Junio C Hamano
In-Reply-To: <alpine.DEB.1.00.0901142104400.3586@pacific.mpi-cbg.de>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Documentation/diff-options.txt | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 2c1fa4b..8689a92 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -91,12 +91,17 @@ endif::git-format-patch[]
Turn off colored diff, even when the configuration file
gives the default to color output.
---color-words[=regex]::
- Show colored word diff, i.e. color words which have changed.
+--color-words[=<regex>]::
+ Show colored word diff, i.e., color words which have changed.
+ By default, words are separated by whitespace.
+
-Optionally, you can pass a regular expression that tells Git what the
-words are that you are looking for; The default is to interpret any
-stretch of non-whitespace as a word.
+When a <regex> is specified, every non-overlapping match of the
+<regex> is considered a word. Anything between these matches is
+considered whitespace and ignored(!) for the purposes of finding
+differences. You may want to append `|[^[:space:]]` to your regular
+expression to make sure that it matches all non-whitespace characters.
+A match that contains a newline is silently truncated(!) at the
+newline.
--no-renames::
Turn off rename detection, even when the configuration
--
1.6.1.142.ge070e
^ permalink raw reply related
* [PATCH 2/4] color-words: enable REG_NEWLINE to help user
From: Thomas Rast @ 2009-01-14 22:26 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Santi Béjar, Junio C Hamano
In-Reply-To: <alpine.DEB.1.00.0901142104400.3586@pacific.mpi-cbg.de>
We silently truncate a match at the newline, which may lead to
unexpected behaviour, e.g., when matching "<[^>]*>" against
<foo
bar>
since then "<foo" becomes a word (and "bar>" doesn't!) even though the
regex said only angle-bracket-delimited things can be words.
To alleviate the problem slightly, use REG_NEWLINE so that negated
classes can't match a newline. Of course newlines can still be
matched explicitly.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
diff.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/diff.c b/diff.c
index cc42adf..3f07ac1 100644
--- a/diff.c
+++ b/diff.c
@@ -1536,7 +1536,8 @@ static void builtin_diff(const char *name_a,
ecbdata.diff_words->word_regex = (regex_t *)
xmalloc(sizeof(regex_t));
if (regcomp(ecbdata.diff_words->word_regex,
- o->word_regex, REG_EXTENDED))
+ o->word_regex,
+ REG_EXTENDED | REG_NEWLINE))
die ("Invalid regular expression: %s",
o->word_regex);
}
--
1.6.1.142.ge070e
^ permalink raw reply related
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