* Re: [PATCH 6/8] sh-tools: add a run_merge_tool function
From: Markus Heidelberg @ 2009-03-30 6:55 UTC (permalink / raw)
To: David Aguilar; +Cc: gitster, git
In-Reply-To: <1238389428-69328-7-git-send-email-davvid@gmail.com>
David Aguilar, 30.03.2009:
> + if mergetool_mode; then
> + base=Baes
Base
> + local=Local
> + remote=Remote
> + else
^ permalink raw reply
* Re: [PATCH] git-gui: make "Git GUI Here" Explorer extension more robust
From: Markus Heidelberg @ 2009-03-30 6:51 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: msysgit, git, Shawn O. Pearce
In-Reply-To: <alpine.DEB.1.00.0903300243050.6454@intel-tinevez-2-302>
Johannes Schindelin, 30.03.2009:
> Hi,
>
> On Mon, 30 Mar 2009, Markus Heidelberg wrote:
>
> > Starting git-gui via Windows Explorer shell extension caused problems
> > when not started from the project directory, but from a directory within
> > the project: starting the Explorer from the git-gui menu "Explore
> > Working Copy" didn't work then.
> >
> > Starting git-gui via Explorer shell extension from the .git directory
> > didn't work at all.
> >
> > To make these things possible, "cd .." until we see .git/
>
> How does this interact with GIT_WORK_TREE?
Not sure. What's the use case for a globally set GIT_WORK_TREE, how is
it used?
> And with bare repositories?
Git-gui doesn't seem to work with bare repositories, I get
"Cannot use funny .git directory: ."
when started on the command line.
But I just noticed, that it will obviously "cd .." forever, if no .git/
was found. Somehow the root directory has to be catched.
Markus
^ permalink raw reply
* Re: [PATCH 1/2] send-email: refactor and ensure prompting doesn't loop forever
From: Junio C Hamano @ 2009-03-30 6:50 UTC (permalink / raw)
To: Jay Soffian; +Cc: git, Matthieu Moy
In-Reply-To: <76718490903281848l5102afc3x89eed40ed6083dcc@mail.gmail.com>
Jay Soffian <jaysoffian@gmail.com> writes:
> On Sat, Mar 28, 2009 at 9:39 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
>> There are three callers of the function:
>
> Where by "three" I mean "four". Please use this commit message instead:
Thanks.
^ permalink raw reply
* Re: [PATCH 2/4] quote: add "sq_dequote_to_argv" to put unwrapped args in an argv array
From: Junio C Hamano @ 2009-03-30 6:48 UTC (permalink / raw)
To: Christian Couder; +Cc: git, John Tapsell, Johannes Schindelin
In-Reply-To: <20090329114452.b19a2f60.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
> This new function unwraps the space separated shell quoted elements in
> its first argument and put a copy of them in the argv array passed as
> its second argument.
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
> quote.c | 17 +++++++++++++++++
> quote.h | 2 ++
> 2 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/quote.c b/quote.c
> index 8cf0ef4..5b12a4a 100644
> --- a/quote.c
> +++ b/quote.c
> @@ -120,6 +120,23 @@ char *sq_dequote(char *arg)
> return sq_dequote_many(arg, NULL);
> }
>
> +int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc)
> +{
> + char *next = arg;
> +
> + if (!*arg)
> + return 0;
> + do {
> + char *dequoted = sq_dequote_many(next, &next);
> + if (!dequoted)
> + return 1;
Usually we signal an error with a negative value, e.g. -1.
> + ALLOC_GROW(*argv, *nr + 1, *alloc);
> + (*argv)[(*nr)++] = xstrdup(dequoted);
The original sq_dequote() interface takes advantage of the fact that the
result of single-quote unquoting is always shorter than the original and
it can rewrite the argument in-place to return the result. I would expect
dequote_step() to retain that trait and allow the caller to use its return
value without xstrdup().
But please do not send in replacements just yet.
^ permalink raw reply
* Re: [PATCH 1/4] quote: implement "sq_dequote_many" to unwrap many args in one string
From: Junio C Hamano @ 2009-03-30 6:45 UTC (permalink / raw)
To: Christian Couder; +Cc: git, John Tapsell, Johannes Schindelin
In-Reply-To: <20090329114444.5579813c.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
> @@ -92,6 +92,8 @@ char *sq_dequote(char *arg)
> switch (*++src) {
> case '\0':
> *dst = 0;
> + if (next)
> + *next = 0;
*next = NULL;
> return arg;
> case '\\':
> c = *++src;
> diff --git a/quote.h b/quote.h
> index c5eea6f..c2f98e7 100644
> --- a/quote.h
> +++ b/quote.h
> @@ -39,6 +39,14 @@ extern void sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen);
> */
> extern char *sq_dequote(char *);
>
> +/*
> + * Same as the above, but can unwraps many arguments in the same string
"can unwrap"
> + * separated by space. "next" is changed to point to the next argument
> + * that should be passed as first parameter. When there are no more
> + * arguments to be dequoted, then "next" is changed to point to NULL.
> + */
> +extern char *sq_dequote_many(char *arg, char **next);
> +
> extern int unquote_c_style(struct strbuf *, const char *quoted, const char **endp);
> extern size_t quote_c_style(const char *name, struct strbuf *, FILE *, int no_dq);
> extern void quote_two_c_style(struct strbuf *, const char *, const char *, int);
I think dequote_many() is misnamed, as it only does one but has a slightly
more helpful interface than the bare sq_dequote() when the caller is
willing to dequote many. It probably should be called dequote_step().
But do not send in replacements just yet.
^ permalink raw reply
* Re: [PATCH] git-svn: don't output git commits in quiet mode
From: Junio C Hamano @ 2009-03-30 6:44 UTC (permalink / raw)
To: Eric Wong; +Cc: Simon Arlott, gitster, git
In-Reply-To: <20090329224324.GB20675@dcvr.yhbt.net>
Eric Wong <normalperson@yhbt.net> writes:
> Simon Arlott <simon@fire.lp0.eu> wrote:
>> Ideally only errors should be output in this mode so fetch
>> can be run from cron and normally produce no output. Without
>> this change it would output a single line on each git commit,
>> e.g.
>> r1909 = 32ef87860662526d4a62f903949ed21e0341079e (u2_10_12_branch)
>>
>> Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
>
> Thanks Simon,
>
> Acked-by: Eric Wong <normalperson@yhbt.net>
>
> and pushed to git://git.bogomips.org/git-svn
... and pulled from there. Thanks, both.
^ permalink raw reply
* Re: [PATCH] git-svn: fix ls-tree usage with dash-prefixed paths
From: Junio C Hamano @ 2009-03-30 6:44 UTC (permalink / raw)
To: Eric Wong; +Cc: git, Anton Gyllenberg
In-Reply-To: <20090329215651.GA4355@dcvr.yhbt.net>
Eric Wong <normalperson@yhbt.net> writes:
> Junio C Hamano <gitster@pobox.com> wrote:
>> Eric Wong <normalperson@yhbt.net> writes:
>>
>> > To find the blob object name given a tree and pathname, we were
>> > incorrectly calling "git ls-tree" with a "--" argument followed
>> > by the pathname of the file we wanted to get.
>> >
>> > git ls-tree <TREE> -- --dashed/path/name.c
>> >
>> > Unlike many command-line interfaces, the "--" alone does not
>> > symbolize the end of non-option arguments on the command-line.
>> >
>> > ls-tree interprets the "--" as a prefix to match against, thus
>> > the entire contents of the --dashed/* hierarchy would be
>> > returned because the "--" matches "--dashed" and every path
>> > under it.
>>
>> The above makes only half a sense to me. In an empty directory:
>
> Ah, I think you missed this line:
>
> "the entire contents of the --dashed/* hierarchy would be"
Actually, that was what I was trying to demonstrate to be false. Notice
the empty output from the first ls-tree with only -- and no other pathspec
on the command line. "--" should not match "--dashed/*" anything (but
also notice that I said "should" here).
>> $ git init
>> Initialized empty Git repository in /tmp/empty/.git
>> $ mkdir -p ./--dashed/path
>> $ >./--dashed/path/name
>
> # Add a second file
> >./--dashed/path/ame
I think that is an independent bug. Not just "--" but it appears "--d"
seems to hit it (and this is an ancient bug---even v1.0.0 seems to have
it).
> [1] But if we had time travel we could just release git before any other
> SCM and hopefully not have to deal with SVN at all :)
;-)
I suspect that ls-tree needs a fix, not about "--" but about the pathspec
filtering. It appears that the part that decides if a subtree is worth
traversing into uses the correct "is a pathspec pattern match leading path
components?" semantics (i.e. "--dashed" matches but "--" doesn't), but
after traversing into subtrees, the part that emits the output uses a
broken semantics "does the path have any pathspec patter as its prefix?"
It shouldn't check for "prefix", but for "leading path components", in
other words, the match must happen at directory boundaries.
And I do not think *this* bug is too late to fix. We should fix it.
^ permalink raw reply
* Re: [EGIT] [PATCH RFC v1 0/5] Add (static) ignore functionality to EGit
From: Robin Rosenberg @ 2009-03-30 6:18 UTC (permalink / raw)
To: Jonathan Gossage; +Cc: Ferry Huberts, git
In-Reply-To: <49D0151B.6070408@magma.ca>
måndag 30 mars 2009 02:40:59 skrev Jonathan Gossage <jgossage@gmail.com>:
> Ferry Huberts wrote:
> Eclipse supplies a repository-independent ignore file list as part of the repository-type independent Team support. A first step, which would provide useful functionality would be to populate your cache with this list and enable it's use in the Egit plugin. This would accomplish the goal of enabling EGit to use ignore lists in an immediately useful way with minimal effort. As a second stage you can add support for picking up Git specific files and updating them from Eclipse.
The current EGit obeys the Eclipse ignore rules already, so no there is no need to hurry just for that feature.
-- robin
^ permalink raw reply
* Re: On git 1.6 (novice's opinion)
From: Russ Dill @ 2009-03-30 6:18 UTC (permalink / raw)
To: Ulrich Windl; +Cc: H.Merijn Brand, git
In-Reply-To: <49CCAF5D.21814.24B4DE63@Ulrich.Windl.rkdvmks1.ngate.uni-regensburg.de>
On Fri, Mar 27, 2009 at 2:50 AM, Ulrich Windl
<ulrich.windl@rz.uni-regensburg.de> wrote:
> On 27 Mar 2009 at 9:05, H.Merijn Brand wrote:
>
>> On Fri, 27 Mar 2009 08:21:36 +0100, "Ulrich Windl"
>> <ulrich.windl@rz.uni-regensburg.de> wrote:
>>
>> > What I'd like to see in git (My apologies if some were already discussed to
>> > death):
>> >
>> > 1) The ability to use the file's time at the time of add/commit instead of
>> > the current time, and the ability tho check outfiles with the times stored
>> > in the repository.
>> >
>> > 2) Keyword substitution. I know it's controverse (dealing with binary files),
>> > but I'd like to have some automatic version numbering keyword at least:
>> > Initial idea is that every commit with a change increments the number by
>> > one, and when merging numbers a and b, the resulting number is max(a, b) + 1.
>>
>> impossible. Even with checkin- and checkout hooks, you won't get that
>> SCCS behaviour. They have to be better in something too :)
>> /me still misses that but got used to it
>
> Hi,
>
> what made me wonder is this (about item 1): I thought I've read that blobs store
> content and attributes, so very obviously I wondered why not store thr "right
> attributes" (i.e. the time of the file). My reasoning: You make some changes, then
> test them (which might last several hours or days). The if I'm happy I'll
> "commit". Naturally I want to see the time of change for each file when the change
> had been actually made, not when the change was committed. Likewise when checking
> out, I want to be able to see the time of modification, not the time of commit.
> I'm aware that many people don't care about such differences...
>
Ok, so if Nancy did some work on the part number form 6 months ago,
but it got merged into master yesterday. What date should the file
have? This kind of incremental version number, and trusting of file
dates really only matters on a centralized system with a single
branch.
Not only that, but modification times are much more useful with make.
Merging or pulling small changes into a tree shouldn't require a full
rebuild of the entire tree which in some cases could take hours.
Especially since 'git log <file>', 'gitk <file>', or 'git blame
<file>' give much more information anyway.
I know some people sort their directory by date to see what kind of
stuff happened since they last worked on the repository, but it
doesn't scale to a project with many directories and the log is much
more useful anyway.
^ permalink raw reply
* Re: [PATCH] git-svn: fix ls-tree usage with dash-prefixed paths
From: Björn Steinbrink @ 2009-03-30 5:28 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Eric Wong, git, Anton Gyllenberg
In-Reply-To: <7v8wmoqdc1.fsf@gitster.siamese.dyndns.org>
On 2009.03.29 13:33:02 -0700, Junio C Hamano wrote:
> Eric Wong <normalperson@yhbt.net> writes:
>
> > To find the blob object name given a tree and pathname, we were
> > incorrectly calling "git ls-tree" with a "--" argument followed
> > by the pathname of the file we wanted to get.
> >
> > git ls-tree <TREE> -- --dashed/path/name.c
> >
> > Unlike many command-line interfaces, the "--" alone does not
> > symbolize the end of non-option arguments on the command-line.
> >
> > ls-tree interprets the "--" as a prefix to match against, thus
> > the entire contents of the --dashed/* hierarchy would be
> > returned because the "--" matches "--dashed" and every path
> > under it.
>
> The above makes only half a sense to me. In an empty directory:
>
> $ git init
> Initialized empty Git repository in /tmp/empty/.git
> $ mkdir -p ./--dashed/path
> $ >./--dashed/path/name
> $ git add .
> $ git ls-files
> --dashed/path/name
> $ git commit -a -m initial
> [master (root-commit) cd44284] initial
> 0 files changed, 0 insertions(+), 0 deletions(-)
> create mode 100644 --dashed/path/name
> $ git ls-tree HEAD^{tree} --
> $ git ls-tree HEAD^{tree} -- --dashed/path/name
> 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 --dashed/path/name
> $ mkdir ./--
> $ >./--/eman
> $ git add .
> $ git commit -m second
> [master 80f8ef9] second
> 0 files changed, 0 insertions(+), 0 deletions(-)
> create mode 100644 --/eman
> $ git ls-tree HEAD^{tree} -- --dashed/path
> 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 --/eman
> 040000 tree 23e59e0c91294c39ac7c5a2e39efb01d878de9a0 --dashed/path
> $ exit
>
> Perhaps the problem repository had a pathname that is exactly -- (in
> addition to --dashed/), and ls-tree emitted everything under --/
> hierarchy? In other words, your fix to git-svn may be correct and I am
> reading your problem description above incorrectly?
Your test case is flawed, because you only have a single path in
--dashed/
Initialized empty Git repository in /home/doener/test/.git/
$ mkdir ./--dashed
$ touch ./--dashed/{1,2}
$ git add .
$ git ls-files
--dashed/1
--dashed/2
$ git commit -m init
[master (root-commit) ae7cd83] init
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 --dashed/1
create mode 100644 --dashed/2
$ git ls-tree HEAD^{tree}
040000 tree f353b342b53872c6a510229524f819c4fe0d5c1b --dashed
$ git ls-tree HEAD^{tree} --
$ git ls-tree HEAD^{tree} -- --dashed
040000 tree f353b342b53872c6a510229524f819c4fe0d5c1b --dashed
$ git ls-tree HEAD^{tree} -- --dashed/
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 --dashed/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 --dashed/2
$ git ls-tree HEAD^{tree} -- --dashed/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 --dashed/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 --dashed/2
Or even more weird (at least to me):
Initialized empty Git repository in /home/doener/test/.git/
$ mkdir foo fab
$ touch {foo,fab}/{1,2}
$ git add .
$ git commit -m init
[master (root-commit) fdb7bb3] init
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 fab/1
create mode 100644 fab/2
create mode 100644 foo/1
create mode 100644 foo/2
$ git ls-files foo/1 fab/1
fab/1
foo/1
$ git ls-files foo/1 fab/1 f
fab/1
foo/1
$ git ls-tree HEAD^{tree} foo/1 fab/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 fab/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 foo/1
$ git ls-tree HEAD^{tree} foo/1 fab/1 f
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 fab/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 fab/2
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 foo/1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 foo/2
So if you go into some tree, any additional pattern that is a prefix of
the tree name will match the tree and its contents.
Björn
^ permalink raw reply
* Re: Implementing stat() with FindFirstFile()
From: Björn Steinbrink @ 2009-03-30 5:11 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Magnus Bäck, Johannes Sixt, git
In-Reply-To: <alpine.DEB.1.00.0903300245080.6454@intel-tinevez-2-302>
On 2009.03.30 02:52:47 +0200, Johannes Schindelin wrote:
> On Mon, 30 Mar 2009, Magnus Bäck wrote:
> > On Friday, March 27, 2009 at 03:25 CET,
> > Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > > On Thu, 26 Mar 2009, Magnus Bäck wrote:
> > > > I'd be very surprised if ZwQueryDirectoryFile() hasn't always been
> > > > around (I just verified ntdll.dll from NT 4.0), so that's not a
> > > > worry. Don't know why MSDN reports it as introduced in XP.
> > >
> > > As the current maintainer of msysGit, I refuse to have something in
> > > the installer I ship that relies on not-at-all guaranteed interfaces.
> >
> > Although I do appreciate the importance of guaranteed interfaces,
> > I am also pragmatic. An incompatible change in ntdll.dll would break
> > vast amounts of programs, including cygwin. There is a lot to be said
> > about Microsoft and their APIs, but I don't think they have a habit of
> > changing ABIs or function semantics for userland libraries that have
> > been around for 15 years.
>
> Had you pointed to some document that states that the function has been in
> all NT-based versions, that would have done the trick.
Not official documentation, but at least from some MS guy it seems:
http://www.osronline.com/showThread.cfm?link=73086 (last message).
Apparently, it was in NT3.x, but they document only what's actually
defined in the header.
Björn, feeling weird for trying to help with some Windows issue...
^ permalink raw reply
* [PATCH 2/2] Add feature release instructions to gitworkflows man page
From: rocketraman @ 2009-03-30 5:35 UTC (permalink / raw)
To: git
In-Reply-To: <1238391319-4953-1-git-send-email-rocketraman@fastmail.fm>
From: Raman Gupta <raman@rocketraman.com>
Based on a mailing list discussion, add a description of the workflow,
and associated commands, for creating a feature release.
Signed-off-by: Raman Gupta <raman@rocketraman.com>
---
Documentation/gitworkflows.txt | 73 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/Documentation/gitworkflows.txt b/Documentation/gitworkflows.txt
index 2b021e3..6a31d7b 100644
--- a/Documentation/gitworkflows.txt
+++ b/Documentation/gitworkflows.txt
@@ -348,6 +348,79 @@ in patches to figure out the merge base. See linkgit:git-am[1] for
other options.
+RELEASE WORKFLOW
+----------------
+
+The maintainer may use the following release workflow:
+
+He first tags the tip of 'master' with a release tag, then he updates
+the 'maint' branch to the current tip of 'master' for managing future
+maintenance fixes on the current release, and lastly he optionally
+rebuilds 'next' from the tip of 'master'.
+
+
+Release Tagging
+~~~~~~~~~~~~~~~
+
+The new feature release is tagged on 'master' with a tag matching
+vX.Y.Z, where X.Y.Z is the new feature release version.
+
+.Release tagging
+[caption="Recipe: "]
+==========================================
+`git tag -s -m "GIT X.Y.Z" vX.Y.Z master`
+==========================================
+
+
+Maintenance branch update
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The current maintenance branch is optionally copied to another branch
+named with the older release version number to allow for further
+maintenance releases on the older codebase. If the current tip of
+maint corresponds to an older release tag, then creating the maint
+branch for the older codebase can also be done later if and when it
+is required.
+
+.Copy maint
+[caption="Recipe: "]
+=====================================
+`git branch maint-X.Y.(Z-1) maint`
+=====================================
+
+'maint' is now updated to the new release code so that maintenance
+fixes can be merged for the current version.
+
+.Update maint to new release
+[caption="Recipe: "]
+=====================================
+* `git branch -f maint master`
+=====================================
+
+This creates 'maint' from 'master', while preserving the 'maint'
+reflog.
+
+
+Update next branch
+~~~~~~~~~~~~~~~~~~
+
+The 'next' branch may be rewound and rebuilt from the tip of 'master'
+using the surviving topics on 'next'.
+
+This step is optional. If it is done by the maintainer, then a public
+announcement will be made indicating that 'next' was rewound and
+rebuilt.
+
+.Update maint to new release
+[caption="Recipe: "]
+=====================================
+* `git branch -f next master`
+* `git merge ai/topic_in_next1`
+* `git merge ai/topic_in_next2`
+* ...
+=====================================
+
+
SEE ALSO
--------
linkgit:gittutorial[7],
--
1.6.2
^ permalink raw reply related
* [PATCH 1/2] Add feature release instructions to MaintNotes addendum
From: rocketraman @ 2009-03-30 5:35 UTC (permalink / raw)
To: git
From: Raman Gupta <raman@rocketraman.com>
Based on a mailing list discussion, add the operations for creating a
feature release.
Signed-off-by: Raman Gupta <raman@rocketraman.com>
---
Documentation/howto/maintain-git.txt | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/Documentation/howto/maintain-git.txt b/Documentation/howto/maintain-git.txt
index 4357e26..f8b7614 100644
--- a/Documentation/howto/maintain-git.txt
+++ b/Documentation/howto/maintain-git.txt
@@ -244,6 +244,27 @@ by doing the following:
repo.or.cz
+A feature release of git is made by tagging 'master' with a tag
+matching vX.Y.Z, where X.Y.Z is the feature release version.
+
+ - Optionally, track the current 'maint' branch to support
+ new releases for the older codebase if necessary.
+
+ $ git branch maint-X.Y.(Z-1) maint
+
+ - The 'maint' branch is updated to the new release.
+
+ $ git branch -f maint master
+
+ - The 'next' branch may be rebuilt from the tip of 'master'
+ using the surviving topics on 'next'.
+
+ $ git branch -f next master
+ $ git merge ai/topic_in_next1
+ $ git merge ai/topic_in_next2
+ ...
+
+
Some observations to be made.
* Each topic is tested individually, and also together with
--
1.6.2
^ permalink raw reply related
* [PATCH v2 2/2] bisect--helper: string output variables together with "&&"
From: Christian Couder @ 2009-03-30 5:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell, Johannes Schindelin
When doing:
eval "git bisect--helper --next-vars" | {
while read line
do
echo "$line &&"
done
echo ':'
}
the result code comes from the last "echo ':'", not from running
"git bisect--helper --next-vars".
This patch get rid of the need to string the line from the output
of "git bisect--helper" by making "git bisect--helper --next-vars"
return output variables stringed together with "&&".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
bisect.c | 3 ++-
bisect.h | 1 +
builtin-rev-list.c | 29 +++++++++++++++++++----------
git-bisect.sh | 15 +--------------
4 files changed, 23 insertions(+), 25 deletions(-)
Sorry, I forgot to put "v2" between "PATH" and "2/2" so
I am resending it.
diff --git a/bisect.c b/bisect.c
index 64a5ad5..df0ab4d 100644
--- a/bisect.c
+++ b/bisect.c
@@ -554,5 +554,6 @@ int bisect_next_vars(const char *prefix)
revs.commits = find_bisection(revs.commits, &reaches, &all,
!!skipped_sha1_nr);
- return show_bisect_vars(&revs, reaches, all, SHOW_TRIED);
+ return show_bisect_vars(&revs, reaches, all,
+ SHOW_TRIED | SHOW_STRINGED);
}
diff --git a/bisect.h b/bisect.h
index 4cff2ba..2e4b2af 100644
--- a/bisect.h
+++ b/bisect.h
@@ -12,6 +12,7 @@ extern struct commit_list *filter_skipped(struct commit_list *list,
/* show_bisect_vars flags */
#define SHOW_ALL 1
#define SHOW_TRIED 2
+#define SHOW_STRINGED 4
/*
* The flag SHOW_ALL should not be set if this function is called
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index c1c4a18..330f7f0 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -226,20 +226,20 @@ static int estimate_bisect_steps(int all)
return (e < 3 * x) ? n : n - 1;
}
-static void show_tried_revs(struct commit_list *tried)
+static void show_tried_revs(struct commit_list *tried, int stringed)
{
printf("bisect_tried='");
for (;tried; tried = tried->next) {
char *format = tried->next ? "%s|" : "%s";
printf(format, sha1_to_hex(tried->item->object.sha1));
}
- printf("'\n");
+ printf(stringed ? "' &&\n" : "'\n");
}
int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
{
int cnt;
- char hex[41] = "";
+ char hex[41] = "", *format;
struct commit_list *tried;
if (!revs->commits && !(flags & SHOW_TRIED))
@@ -269,13 +269,22 @@ int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
}
if (flags & SHOW_TRIED)
- show_tried_revs(tried);
- printf("bisect_rev=%s\n"
- "bisect_nr=%d\n"
- "bisect_good=%d\n"
- "bisect_bad=%d\n"
- "bisect_all=%d\n"
- "bisect_steps=%d\n",
+ show_tried_revs(tried, flags & SHOW_STRINGED);
+ format = (flags & SHOW_STRINGED) ?
+ "bisect_rev=%s &&\n"
+ "bisect_nr=%d &&\n"
+ "bisect_good=%d &&\n"
+ "bisect_bad=%d &&\n"
+ "bisect_all=%d &&\n"
+ "bisect_steps=%d\n"
+ :
+ "bisect_rev=%s\n"
+ "bisect_nr=%d\n"
+ "bisect_good=%d\n"
+ "bisect_bad=%d\n"
+ "bisect_all=%d\n"
+ "bisect_steps=%d\n";
+ printf(format,
hex,
cnt - 1,
all - reaches - 1,
diff --git a/git-bisect.sh b/git-bisect.sh
index 0f7590d..5074dda 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -279,18 +279,6 @@ bisect_auto_next() {
bisect_next_check && bisect_next || :
}
-eval_and_string_together() {
- _eval="$1"
-
- eval "$_eval" | {
- while read line
- do
- echo "$line &&"
- done
- echo ':'
- }
-}
-
exit_if_skipped_commits () {
_tried=$1
_bad=$2
@@ -429,8 +417,7 @@ bisect_next() {
test "$?" -eq "1" && return
# Get bisection information
- eval="git bisect--helper --next-vars" &&
- eval=$(eval_and_string_together "$eval") &&
+ eval=$(eval "git bisect--helper --next-vars") &&
eval "$eval" || exit
if [ -z "$bisect_rev" ]; then
--
1.6.2.1.404.gb0085.dirty
^ permalink raw reply related
* [PATCH 8/8] difftool: refactor git-difftool-helper to use run_merge_tool
From: David Aguilar @ 2009-03-30 5:03 UTC (permalink / raw)
To: gitster; +Cc: git, David Aguilar
In-Reply-To: <1238389428-69328-8-git-send-email-davvid@gmail.com>
This removes most of the duplicated code in git-difftool-helper.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-difftool-helper.sh | 67 ++++-------------------------------------------
1 files changed, 6 insertions(+), 61 deletions(-)
diff --git a/git-difftool-helper.sh b/git-difftool-helper.sh
index 2051a35..d90277b 100755
--- a/git-difftool-helper.sh
+++ b/git-difftool-helper.sh
@@ -10,6 +10,11 @@
TOOL_MODE=diff
. git-sh-tools
+base_present()
+{
+ return 1
+}
+
# difftool.prompt controls the default prompt/no-prompt behavior
# and is overridden with $GIT_DIFFTOOL*_PROMPT.
should_prompt () {
@@ -42,67 +47,7 @@ launch_merge_tool () {
fi
# Run the appropriate merge tool command
- case "$merge_tool" in
- kdiff3)
- basename=$(basename "$MERGED")
- "$merge_tool_path" --auto \
- --L1 "$basename (A)" \
- --L2 "$basename (B)" \
- -o "$MERGED" "$LOCAL" "$REMOTE" \
- > /dev/null 2>&1
- ;;
-
- kompare)
- "$merge_tool_path" "$LOCAL" "$REMOTE"
- ;;
-
- tkdiff)
- "$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
- ;;
-
- meld)
- "$merge_tool_path" "$LOCAL" "$REMOTE"
- ;;
-
- vimdiff)
- "$merge_tool_path" -c "wincmd l" "$LOCAL" "$REMOTE"
- ;;
-
- gvimdiff)
- "$merge_tool_path" -c "wincmd l" -f "$LOCAL" "$REMOTE"
- ;;
-
- xxdiff)
- "$merge_tool_path" \
- -X \
- -R 'Accel.SaveAsMerged: "Ctrl-S"' \
- -R 'Accel.Search: "Ctrl+F"' \
- -R 'Accel.SearchForward: "Ctrl-G"' \
- --merged-file "$MERGED" \
- "$LOCAL" "$REMOTE"
- ;;
-
- opendiff)
- "$merge_tool_path" "$LOCAL" "$REMOTE" \
- -merge "$MERGED" | cat
- ;;
-
- ecmerge)
- "$merge_tool_path" "$LOCAL" "$REMOTE" \
- --default --mode=merge2 --to="$MERGED"
- ;;
-
- emerge)
- "$merge_tool_path" -f emerge-files-command \
- "$LOCAL" "$REMOTE" "$(basename "$MERGED")"
- ;;
-
- *)
- if test -n "$merge_tool_cmd"; then
- ( eval $merge_tool_cmd )
- fi
- ;;
- esac
+ run_merge_tool "$merge_tool"
}
# Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values
--
1.6.1.3
^ permalink raw reply related
* [PATCH 7/8] mergetool: refactor git-mergetool to use run_merge_tool
From: David Aguilar @ 2009-03-30 5:03 UTC (permalink / raw)
To: gitster; +Cc: git, David Aguilar
In-Reply-To: <1238389428-69328-7-git-send-email-davvid@gmail.com>
This removes most of the duplicated code in git-mergetool.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-mergetool.sh | 106 ++----------------------------------------------------
1 files changed, 3 insertions(+), 103 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index ec20030..0f5033c 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -191,109 +191,9 @@ merge_file () {
read ans
fi
- case "$merge_tool" in
- kdiff3)
- if base_present ; then
- ("$merge_tool_path" --auto \
- --L1 "$MERGED (Base)" \
- --L2 "$MERGED (Local)" \
- --L3 "$MERGED (Remote)" \
- -o "$MERGED" "$BASE" "$LOCAL" "$REMOTE" \
- > /dev/null 2>&1)
- else
- ("$merge_tool_path" --auto \
- --L1 "$MERGED (Local)" \
- --L2 "$MERGED (Remote)" \
- -o "$MERGED" "$LOCAL" "$REMOTE" \
- > /dev/null 2>&1)
- fi
- status=$?
- ;;
- tkdiff)
- if base_present ; then
- "$merge_tool_path" -a "$BASE" -o "$MERGED" "$LOCAL" "$REMOTE"
- else
- "$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
- fi
- status=$?
- ;;
- meld)
- touch "$BACKUP"
- "$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
- check_unchanged
- ;;
- vimdiff)
- touch "$BACKUP"
- "$merge_tool_path" -c "wincmd l" "$LOCAL" "$MERGED" "$REMOTE"
- check_unchanged
- ;;
- gvimdiff)
- touch "$BACKUP"
- "$merge_tool_path" -c "wincmd l" -f "$LOCAL" "$MERGED" "$REMOTE"
- check_unchanged
- ;;
- xxdiff)
- touch "$BACKUP"
- if base_present ; then
- "$merge_tool_path" -X --show-merged-pane \
- -R 'Accel.SaveAsMerged: "Ctrl-S"' \
- -R 'Accel.Search: "Ctrl+F"' \
- -R 'Accel.SearchForward: "Ctrl-G"' \
- --merged-file "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
- else
- "$merge_tool_path" -X --show-merged-pane \
- -R 'Accel.SaveAsMerged: "Ctrl-S"' \
- -R 'Accel.Search: "Ctrl+F"' \
- -R 'Accel.SearchForward: "Ctrl-G"' \
- --merged-file "$MERGED" "$LOCAL" "$REMOTE"
- fi
- check_unchanged
- ;;
- opendiff)
- touch "$BACKUP"
- if base_present; then
- "$merge_tool_path" "$LOCAL" "$REMOTE" \
- -ancestor "$BASE" -merge "$MERGED" | cat
- else
- "$merge_tool_path" "$LOCAL" "$REMOTE" \
- -merge "$MERGED" | cat
- fi
- check_unchanged
- ;;
- ecmerge)
- touch "$BACKUP"
- if base_present; then
- "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" \
- --default --mode=merge3 --to="$MERGED"
- else
- "$merge_tool_path" "$LOCAL" "$REMOTE" \
- --default --mode=merge2 --to="$MERGED"
- fi
- check_unchanged
- ;;
- emerge)
- if base_present ; then
- "$merge_tool_path" -f emerge-files-with-ancestor-command \
- "$LOCAL" "$REMOTE" "$BASE" "$(basename "$MERGED")"
- else
- "$merge_tool_path" -f emerge-files-command \
- "$LOCAL" "$REMOTE" "$(basename "$MERGED")"
- fi
- status=$?
- ;;
- *)
- if test -n "$merge_tool_cmd"; then
- if test "$merge_tool_trust_exit_code" = "false"; then
- touch "$BACKUP"
- ( eval $merge_tool_cmd )
- check_unchanged
- else
- ( eval $merge_tool_cmd )
- status=$?
- fi
- fi
- ;;
- esac
+ run_merge_tool "$merge_tool"
+ status=$?
+
if test "$status" -ne 0; then
echo "merge of $MERGED failed" 1>&2
mv -- "$BACKUP" "$MERGED"
--
1.6.1.3
^ permalink raw reply related
* [PATCH 6/8] sh-tools: add a run_merge_tool function
From: David Aguilar @ 2009-03-30 5:03 UTC (permalink / raw)
To: gitster; +Cc: git, David Aguilar
In-Reply-To: <1238389428-69328-6-git-send-email-davvid@gmail.com>
This function launches merge tools and will be used to refactor
git-(diff|merge)tool.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
Documentation/git-sh-tools.txt | 3 +
git-sh-tools.sh | 147 +++++++++++++++++++++++++++++++++++++--
2 files changed, 142 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-sh-tools.txt b/Documentation/git-sh-tools.txt
index 055a10c..68d1b37 100644
--- a/Documentation/git-sh-tools.txt
+++ b/Documentation/git-sh-tools.txt
@@ -36,6 +36,9 @@ init_merge_tool_path::
sets up `$merge_tool_path` according to '(diff|merge)tool.<tool>.path'
configurations.
+run_merge_tool::
+ runs the specified merge tool.
+
Author
------
Written by David Aguilar <davvid@gmail.com>
diff --git a/git-sh-tools.sh b/git-sh-tools.sh
index 234bac7..5c7bd18 100644
--- a/git-sh-tools.sh
+++ b/git-sh-tools.sh
@@ -12,29 +12,34 @@ valid_tool() {
esac
}
+# Test whether we're in merge mode
+mergetool_mode()
+{
+ test "$TOOL_MODE" = "merge"
+}
+
# Verifies that (difftool|mergetool).<tool>.cmd exists
# Requires $TOOL_MODE to be set.
valid_custom_tool() {
- if test "$TOOL_MODE" = "diff"; then
- merge_tool_cmd="$(git config difftool.$1.cmd)"
- test -z "$merge_tool_cmd" &&
+ if mergetool_mode; then
merge_tool_cmd="$(git config mergetool.$1.cmd)"
test -n "$merge_tool_cmd"
- elif test "$TOOL_MODE" = "merge"; then
+ else
+ merge_tool_cmd="$(git config difftool.$1.cmd)"
+ test -z "$merge_tool_cmd" &&
merge_tool_cmd="$(git config mergetool.$1.cmd)"
test -n "$merge_tool_cmd"
fi
}
-
# Set up $merge_tool_path for (diff|merge)tool.<tool>.path configurations
init_merge_tool_path() {
- if test "$TOOL_MODE" = "diff"; then
+ if mergetool_mode; then
+ merge_tool_path=$(git config mergetool."$1".path)
+ else
merge_tool_path=$(git config difftool."$1".path)
test -z "$merge_tool_path" &&
merge_tool_path=$(git config mergetool."$1".path)
- elif test "$TOOL_MODE" = "merge"; then
- merge_tool_path=$(git config mergetool."$1".path)
fi
if test -z "$merge_tool_path" ; then
@@ -48,3 +53,129 @@ init_merge_tool_path() {
esac
fi
}
+
+# Runs a side-by-side merge tool
+run_merge_tool()
+{
+ merge_tool="$1"
+
+ # base_present is always false when !mergetool_mode
+ case "$merge_tool" in
+ kdiff3)
+ if mergetool_mode; then
+ base=Baes
+ local=Local
+ remote=Remote
+ else
+ base=A
+ local=A
+ remote=B
+ fi
+ if base_present; then
+ ("$merge_tool_path" --auto \
+ --L1 "$MERGED ($base)" \
+ --L2 "$MERGED ($local)" \
+ --L3 "$MERGED ($remote)" \
+ -o "$MERGED" "$BASE" "$LOCAL" "$REMOTE" \
+ > /dev/null 2>&1)
+ else
+ ("$merge_tool_path" --auto \
+ --L1 "$MERGED ($local)" \
+ --L2 "$MERGED ($remote)" \
+ -o "$MERGED" "$LOCAL" "$REMOTE" \
+ > /dev/null 2>&1)
+ fi
+ status=$?
+ ;;
+ tkdiff)
+ if base_present; then
+ "$merge_tool_path" -a "$BASE" -o "$MERGED" "$LOCAL" "$REMOTE"
+ else
+ "$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
+ fi
+ status=$?
+ ;;
+ meld)
+ mergetool_mode && touch "$BACKUP"
+ "$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
+ mergetool_mode && check_unchanged
+ ;;
+ vimdiff)
+ mergetool_mode && touch "$BACKUP"
+ "$merge_tool_path" -c "wincmd l" "$LOCAL" "$MERGED" "$REMOTE"
+ mergetool_mode && check_unchanged
+ ;;
+ gvimdiff)
+ mergetool_mode && touch "$BACKUP"
+ "$merge_tool_path" -c "wincmd l" -f "$LOCAL" "$MERGED" "$REMOTE"
+ mergetool_mode && check_unchanged
+ ;;
+ xxdiff)
+ if mergetool_mode; then
+ touch "$BACKUP"
+ xtra_args='--show-merged-pane'
+ else
+ xtra_args=
+ fi
+ if base_present; then
+ "$merge_tool_path" -X $xtra_args \
+ -R 'Accel.SaveAsMerged: "Ctrl-S"' \
+ -R 'Accel.Search: "Ctrl+F"' \
+ -R 'Accel.SearchForward: "Ctrl-G"' \
+ --merged-file "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
+ else
+ "$merge_tool_path" -X $xtra_args \
+ -R 'Accel.SaveAsMerged: "Ctrl-S"' \
+ -R 'Accel.Search: "Ctrl+F"' \
+ -R 'Accel.SearchForward: "Ctrl-G"' \
+ --merged-file "$MERGED" "$LOCAL" "$REMOTE"
+ fi
+ mergetool_mode && check_unchanged
+ ;;
+ opendiff)
+ mergetool_mode && touch "$BACKUP"
+ if base_present; then
+ "$merge_tool_path" "$LOCAL" "$REMOTE" \
+ -ancestor "$BASE" -merge "$MERGED" | cat
+ else
+ "$merge_tool_path" "$LOCAL" "$REMOTE" \
+ -merge "$MERGED" | cat
+ fi
+ mergetool_mode && check_unchanged
+ ;;
+ ecmerge)
+ mergetool_mode && touch "$BACKUP"
+ if base_present; then
+ "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" \
+ --default --mode=merge3 --to="$MERGED"
+ else
+ "$merge_tool_path" "$LOCAL" "$REMOTE" \
+ --default --mode=merge2 --to="$MERGED"
+ fi
+ mergetool_mode && check_unchanged
+ ;;
+ emerge)
+ if base_present ; then
+ "$merge_tool_path" -f emerge-files-with-ancestor-command \
+ "$LOCAL" "$REMOTE" "$BASE" "$(basename "$MERGED")"
+ else
+ "$merge_tool_path" -f emerge-files-command \
+ "$LOCAL" "$REMOTE" "$(basename "$MERGED")"
+ fi
+ status=$?
+ ;;
+ *)
+ if test -n "$merge_tool_cmd"; then
+ if test "$merge_tool_trust_exit_code" = "false"; then
+ mergetool_mode && touch "$BACKUP"
+ ( eval $merge_tool_cmd )
+ mergetool_mode && check_unchanged
+ else
+ ( eval $merge_tool_cmd )
+ status=$?
+ fi
+ fi
+ ;;
+ esac
+ return $status
+}
--
1.6.1.3
^ permalink raw reply related
* [PATCH 5/8] difftool: refactor git-difftool to use git-sh-tools
From: David Aguilar @ 2009-03-30 5:03 UTC (permalink / raw)
To: gitster; +Cc: git, David Aguilar
In-Reply-To: <1238389428-69328-5-git-send-email-davvid@gmail.com>
This removes the common valid_tool functions from git-difftool.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-difftool-helper.sh | 45 +++------------------------------------------
1 files changed, 3 insertions(+), 42 deletions(-)
diff --git a/git-difftool-helper.sh b/git-difftool-helper.sh
index 02bb135..2051a35 100755
--- a/git-difftool-helper.sh
+++ b/git-difftool-helper.sh
@@ -7,6 +7,9 @@
#
# Copyright (c) 2009 David Aguilar
+TOOL_MODE=diff
+. git-sh-tools
+
# difftool.prompt controls the default prompt/no-prompt behavior
# and is overridden with $GIT_DIFFTOOL*_PROMPT.
should_prompt () {
@@ -102,48 +105,6 @@ launch_merge_tool () {
esac
}
-# Verifies that (difftool|mergetool).<tool>.cmd exists
-valid_custom_tool() {
- merge_tool_cmd="$(git config difftool.$1.cmd)"
- test -z "$merge_tool_cmd" &&
- merge_tool_cmd="$(git config mergetool.$1.cmd)"
- test -n "$merge_tool_cmd"
-}
-
-# Verifies that the chosen merge tool is properly setup.
-# Built-in merge tools are always valid.
-valid_tool() {
- case "$1" in
- kdiff3 | kompare | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
- ;; # happy
- *)
- if ! valid_custom_tool "$1"
- then
- return 1
- fi
- ;;
- esac
-}
-
-# Sets up the merge_tool_path variable.
-# This handles the difftool.<tool>.path configuration.
-# This also falls back to mergetool defaults.
-init_merge_tool_path() {
- merge_tool_path=$(git config difftool."$1".path)
- test -z "$merge_tool_path" &&
- merge_tool_path=$(git config mergetool."$1".path)
- if test -z "$merge_tool_path"; then
- case "$1" in
- emerge)
- merge_tool_path=emacs
- ;;
- *)
- merge_tool_path="$1"
- ;;
- esac
- fi
-}
-
# Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values
test -n "$GIT_MERGE_TOOL" && merge_tool="$GIT_MERGE_TOOL"
test -n "$GIT_DIFF_TOOL" && merge_tool="$GIT_DIFF_TOOL"
--
1.6.1.3
^ permalink raw reply related
* [PATCH 4/8] mergetool: refactor git-mergetool to use git-sh-tools
From: David Aguilar @ 2009-03-30 5:03 UTC (permalink / raw)
To: gitster; +Cc: git, David Aguilar
In-Reply-To: <1238389428-69328-4-git-send-email-davvid@gmail.com>
This removes the common valid_tool functions from git-mergetool.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-mergetool.sh | 35 ++---------------------------------
1 files changed, 2 insertions(+), 33 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 5ea126c..ec20030 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -11,7 +11,9 @@
USAGE='[--tool=tool] [-y|--no-prompt|--prompt] [file to merge] ...'
SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
+TOOL_MODE=merge
. git-sh-setup
+. git-sh-tools
require_work_tree
# Returns true if the mode reflects a symlink
@@ -351,39 +353,6 @@ do
shift
done
-valid_custom_tool()
-{
- merge_tool_cmd="$(git config mergetool.$1.cmd)"
- test -n "$merge_tool_cmd"
-}
-
-valid_tool() {
- case "$1" in
- kdiff3 | tkdiff | xxdiff | meld | opendiff | \
- emerge | vimdiff | gvimdiff | ecmerge)
- ;; # happy
- *)
- if ! valid_custom_tool "$1"; then
- return 1
- fi
- ;;
- esac
-}
-
-init_merge_tool_path() {
- merge_tool_path=$(git config mergetool.$1.path)
- if test -z "$merge_tool_path" ; then
- case "$1" in
- emerge)
- merge_tool_path=emacs
- ;;
- *)
- merge_tool_path=$1
- ;;
- esac
- fi
-}
-
prompt_after_failed_merge() {
while true; do
printf "Continue merging other unresolved paths (y/n) ? "
--
1.6.1.3
^ permalink raw reply related
* [PATCH 3/8] sh-tools: add a git-sh-tools shell helper script
From: David Aguilar @ 2009-03-30 5:03 UTC (permalink / raw)
To: gitster; +Cc: git, David Aguilar
In-Reply-To: <1238389428-69328-3-git-send-email-davvid@gmail.com>
git-sh-tools holds functions common to the git-*tool commands.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
.gitignore | 1 +
Documentation/git-sh-tools.txt | 49 +++++++++++++++++++++++++++++++++++++++
Makefile | 1 +
command-list.txt | 1 +
git-sh-tools.sh | 50 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 102 insertions(+), 0 deletions(-)
create mode 100644 Documentation/git-sh-tools.txt
create mode 100644 git-sh-tools.sh
diff --git a/.gitignore b/.gitignore
index 966c886..cecf77e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -114,6 +114,7 @@ git-rm
git-send-email
git-send-pack
git-sh-setup
+git-sh-tools
git-shell
git-shortlog
git-show
diff --git a/Documentation/git-sh-tools.txt b/Documentation/git-sh-tools.txt
new file mode 100644
index 0000000..055a10c
--- /dev/null
+++ b/Documentation/git-sh-tools.txt
@@ -0,0 +1,49 @@
+git-sh-tool(1)
+==============
+
+NAME
+----
+git-sh-tools - Common git *tool shell script functions
+
+SYNOPSIS
+--------
+'. "$(git --exec-path)/git-sh-tools"'
+
+DESCRIPTION
+-----------
+
+This is not a command the end user would want to run. Ever.
+This documentation is meant for people who are studying the
+Porcelain-ish scripts and/or are writing new ones.
+
+The 'git-sh-tools' scriptlet is designed to be sourced (using
+`.`) by other shell scripts to set up some functions for
+working with git merge/diff tools.
+
+Before sourcing it, your script should set up a few variables;
+`TOOL_MODE` is used to define the operation mode for various
+functions. 'diff' and 'merge' are valid values.
+
+FUNCTIONS
+---------
+valid_tool::
+ verifies that the specified merge tool is properly setup.
+
+valid_custom_tool::
+ verifies that a '(diff|merge)tool.<tool>.cmd' configuration exists.
+
+init_merge_tool_path::
+ sets up `$merge_tool_path` according to '(diff|merge)tool.<tool>.path'
+ configurations.
+
+Author
+------
+Written by David Aguilar <davvid@gmail.com>
+
+Documentation
+--------------
+Documentation by David Aguilar and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Makefile b/Makefile
index d77fd71..3b7c20f 100644
--- a/Makefile
+++ b/Makefile
@@ -292,6 +292,7 @@ SCRIPT_SH += git-rebase.sh
SCRIPT_SH += git-repack.sh
SCRIPT_SH += git-request-pull.sh
SCRIPT_SH += git-sh-setup.sh
+SCRIPT_SH += git-sh-tools.sh
SCRIPT_SH += git-stash.sh
SCRIPT_SH += git-submodule.sh
SCRIPT_SH += git-web--browse.sh
diff --git a/command-list.txt b/command-list.txt
index fb03a2e..c3b6c87 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -109,6 +109,7 @@ git-show-branch ancillaryinterrogators
git-show-index plumbinginterrogators
git-show-ref plumbinginterrogators
git-sh-setup purehelpers
+git-sh-tools purehelpers
git-stash mainporcelain
git-status mainporcelain common
git-stripspace purehelpers
diff --git a/git-sh-tools.sh b/git-sh-tools.sh
new file mode 100644
index 0000000..234bac7
--- /dev/null
+++ b/git-sh-tools.sh
@@ -0,0 +1,50 @@
+# Verifies that the chosen merge tool is properly setup.
+# Built-in merge tools are always valid.
+valid_tool() {
+ case "$1" in
+ kdiff3 | kompare | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
+ ;; # happy
+ *)
+ if ! valid_custom_tool "$1"; then
+ return 1
+ fi
+ ;;
+ esac
+}
+
+# Verifies that (difftool|mergetool).<tool>.cmd exists
+# Requires $TOOL_MODE to be set.
+valid_custom_tool() {
+ if test "$TOOL_MODE" = "diff"; then
+ merge_tool_cmd="$(git config difftool.$1.cmd)"
+ test -z "$merge_tool_cmd" &&
+ merge_tool_cmd="$(git config mergetool.$1.cmd)"
+ test -n "$merge_tool_cmd"
+ elif test "$TOOL_MODE" = "merge"; then
+ merge_tool_cmd="$(git config mergetool.$1.cmd)"
+ test -n "$merge_tool_cmd"
+ fi
+}
+
+
+# Set up $merge_tool_path for (diff|merge)tool.<tool>.path configurations
+init_merge_tool_path() {
+ if test "$TOOL_MODE" = "diff"; then
+ merge_tool_path=$(git config difftool."$1".path)
+ test -z "$merge_tool_path" &&
+ merge_tool_path=$(git config mergetool."$1".path)
+ elif test "$TOOL_MODE" = "merge"; then
+ merge_tool_path=$(git config mergetool."$1".path)
+ fi
+
+ if test -z "$merge_tool_path" ; then
+ case "$1" in
+ emerge)
+ merge_tool_path=emacs
+ ;;
+ *)
+ merge_tool_path=$1
+ ;;
+ esac
+ fi
+}
--
1.6.1.3
^ permalink raw reply related
* [PATCH 1/8] mergetool: use tabs consistently
From: David Aguilar @ 2009-03-30 5:03 UTC (permalink / raw)
To: gitster; +Cc: git, David Aguilar
In-Reply-To: <1238389428-69328-1-git-send-email-davvid@gmail.com>
This makes mergetool use hard tabs throughout.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-mergetool.sh | 694 +++++++++++++++++++++++++++--------------------------
1 files changed, 354 insertions(+), 340 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 87fa88a..cfee28e 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -16,336 +16,351 @@ require_work_tree
# Returns true if the mode reflects a symlink
is_symlink () {
- test "$1" = 120000
+ test "$1" = 120000
}
local_present () {
- test -n "$local_mode"
+ test -n "$local_mode"
}
remote_present () {
- test -n "$remote_mode"
+ test -n "$remote_mode"
}
base_present () {
- test -n "$base_mode"
+ test -n "$base_mode"
}
cleanup_temp_files () {
- if test "$1" = --save-backup ; then
- mv -- "$BACKUP" "$MERGED.orig"
- rm -f -- "$LOCAL" "$REMOTE" "$BASE"
- else
- rm -f -- "$LOCAL" "$REMOTE" "$BASE" "$BACKUP"
- fi
+ if test "$1" = --save-backup ; then
+ mv -- "$BACKUP" "$MERGED.orig"
+ rm -f -- "$LOCAL" "$REMOTE" "$BASE"
+ else
+ rm -f -- "$LOCAL" "$REMOTE" "$BASE" "$BACKUP"
+ fi
}
describe_file () {
- mode="$1"
- branch="$2"
- file="$3"
-
- printf " {%s}: " "$branch"
- if test -z "$mode"; then
- echo "deleted"
- elif is_symlink "$mode" ; then
- echo "a symbolic link -> '$(cat "$file")'"
- else
- if base_present; then
- echo "modified"
+ mode="$1"
+ branch="$2"
+ file="$3"
+
+ printf " {%s}: " "$branch"
+ if test -z "$mode"; then
+ echo "deleted"
+ elif is_symlink "$mode" ; then
+ echo "a symbolic link -> '$(cat "$file")'"
else
- echo "created"
+ if base_present; then
+ echo "modified"
+ else
+ echo "created"
+ fi
fi
- fi
}
resolve_symlink_merge () {
- while true; do
- printf "Use (l)ocal or (r)emote, or (a)bort? "
- read ans
- case "$ans" in
- [lL]*)
- git checkout-index -f --stage=2 -- "$MERGED"
- git add -- "$MERGED"
- cleanup_temp_files --save-backup
- return 0
- ;;
- [rR]*)
- git checkout-index -f --stage=3 -- "$MERGED"
- git add -- "$MERGED"
- cleanup_temp_files --save-backup
- return 0
- ;;
- [aA]*)
- return 1
- ;;
- esac
+ while true; do
+ printf "Use (l)ocal or (r)emote, or (a)bort? "
+ read ans
+ case "$ans" in
+ [lL]*)
+ git checkout-index -f --stage=2 -- "$MERGED"
+ git add -- "$MERGED"
+ cleanup_temp_files --save-backup
+ return 0
+ ;;
+ [rR]*)
+ git checkout-index -f --stage=3 -- "$MERGED"
+ git add -- "$MERGED"
+ cleanup_temp_files --save-backup
+ return 0
+ ;;
+ [aA]*)
+ return 1
+ ;;
+ esac
done
}
resolve_deleted_merge () {
- while true; do
- if base_present; then
- printf "Use (m)odified or (d)eleted file, or (a)bort? "
- else
- printf "Use (c)reated or (d)eleted file, or (a)bort? "
- fi
- read ans
- case "$ans" in
- [mMcC]*)
- git add -- "$MERGED"
- cleanup_temp_files --save-backup
- return 0
- ;;
- [dD]*)
- git rm -- "$MERGED" > /dev/null
- cleanup_temp_files
- return 0
- ;;
- [aA]*)
- return 1
- ;;
- esac
+ while true; do
+ if base_present; then
+ printf "Use (m)odified or (d)eleted file, or (a)bort? "
+ else
+ printf "Use (c)reated or (d)eleted file, or (a)bort? "
+ fi
+ read ans
+ case "$ans" in
+ [mMcC]*)
+ git add -- "$MERGED"
+ cleanup_temp_files --save-backup
+ return 0
+ ;;
+ [dD]*)
+ git rm -- "$MERGED" > /dev/null
+ cleanup_temp_files
+ return 0
+ ;;
+ [aA]*)
+ return 1
+ ;;
+ esac
done
}
check_unchanged () {
- if test "$MERGED" -nt "$BACKUP" ; then
- status=0;
- else
- while true; do
- echo "$MERGED seems unchanged."
- printf "Was the merge successful? [y/n] "
- read answer < /dev/tty
- case "$answer" in
- y*|Y*) status=0; break ;;
- n*|N*) status=1; break ;;
- esac
- done
- fi
+ if test "$MERGED" -nt "$BACKUP" ; then
+ status=0;
+ else
+ while true; do
+ echo "$MERGED seems unchanged."
+ printf "Was the merge successful? [y/n] "
+ read answer < /dev/tty
+ case "$answer" in
+ y*|Y*) status=0; break ;;
+ n*|N*) status=1; break ;;
+ esac
+ done
+ fi
}
checkout_staged_file () {
- tmpfile=$(expr "$(git checkout-index --temp --stage="$1" "$2")" : '\([^ ]*\) ')
+ checkouttmp=$(git checkout-index --temp --stage="$1" "$2")
+ tmpfile=$(expr "$checkouttmp" : '\([^ ]*\) ')
- if test $? -eq 0 -a -n "$tmpfile" ; then
- mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3"
- fi
+ if test $? -eq 0 -a -n "$tmpfile" ; then
+ mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3"
+ fi
}
merge_file () {
- MERGED="$1"
+ MERGED="$1"
- f=`git ls-files -u -- "$MERGED"`
- if test -z "$f" ; then
- if test ! -f "$MERGED" ; then
- echo "$MERGED: file not found"
- else
- echo "$MERGED: file does not need merging"
+ f=`git ls-files -u -- "$MERGED"`
+ if test -z "$f" ; then
+ if test ! -f "$MERGED" ; then
+ echo "$MERGED: file not found"
+ else
+ echo "$MERGED: file does not need merging"
+ fi
+ return 1
fi
- return 1
- fi
-
- ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
- BACKUP="./$MERGED.BACKUP.$ext"
- LOCAL="./$MERGED.LOCAL.$ext"
- REMOTE="./$MERGED.REMOTE.$ext"
- BASE="./$MERGED.BASE.$ext"
- mv -- "$MERGED" "$BACKUP"
- cp -- "$BACKUP" "$MERGED"
-
- base_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}'`
- local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
- remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
+ ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
+ BACKUP="./$MERGED.BACKUP.$ext"
+ LOCAL="./$MERGED.LOCAL.$ext"
+ REMOTE="./$MERGED.REMOTE.$ext"
+ BASE="./$MERGED.BASE.$ext"
+
+ mv -- "$MERGED" "$BACKUP"
+ cp -- "$BACKUP" "$MERGED"
+
+ base_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}'`
+ local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
+ remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
+
+ base_present && checkout_staged_file 1 "$MERGED" "$BASE"
+ local_present && checkout_staged_file 2 "$MERGED" "$LOCAL"
+ remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
+
+ if test -z "$local_mode" -o -z "$remote_mode"; then
+ echo "Deleted merge conflict for '$MERGED':"
+ describe_file "$local_mode" "local" "$LOCAL"
+ describe_file "$remote_mode" "remote" "$REMOTE"
+ resolve_deleted_merge
+ return
+ fi
- base_present && checkout_staged_file 1 "$MERGED" "$BASE"
- local_present && checkout_staged_file 2 "$MERGED" "$LOCAL"
- remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
+ if is_symlink "$local_mode" || is_symlink "$remote_mode"; then
+ echo "Symbolic link merge conflict for '$MERGED':"
+ describe_file "$local_mode" "local" "$LOCAL"
+ describe_file "$remote_mode" "remote" "$REMOTE"
+ resolve_symlink_merge
+ return
+ fi
- if test -z "$local_mode" -o -z "$remote_mode"; then
- echo "Deleted merge conflict for '$MERGED':"
+ echo "Normal merge conflict for '$MERGED':"
describe_file "$local_mode" "local" "$LOCAL"
describe_file "$remote_mode" "remote" "$REMOTE"
- resolve_deleted_merge
- return
- fi
+ if "$prompt" = true; then
+ printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
+ read ans
+ fi
- if is_symlink "$local_mode" || is_symlink "$remote_mode"; then
- echo "Symbolic link merge conflict for '$MERGED':"
- describe_file "$local_mode" "local" "$LOCAL"
- describe_file "$remote_mode" "remote" "$REMOTE"
- resolve_symlink_merge
- return
- fi
-
- echo "Normal merge conflict for '$MERGED':"
- describe_file "$local_mode" "local" "$LOCAL"
- describe_file "$remote_mode" "remote" "$REMOTE"
- if "$prompt" = true; then
- printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
- read ans
- fi
-
- case "$merge_tool" in
+ case "$merge_tool" in
kdiff3)
- if base_present ; then
- ("$merge_tool_path" --auto --L1 "$MERGED (Base)" --L2 "$MERGED (Local)" --L3 "$MERGED (Remote)" \
- -o "$MERGED" "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
- else
- ("$merge_tool_path" --auto --L1 "$MERGED (Local)" --L2 "$MERGED (Remote)" \
- -o "$MERGED" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
- fi
- status=$?
- ;;
+ if base_present ; then
+ ("$merge_tool_path" --auto \
+ --L1 "$MERGED (Base)" \
+ --L2 "$MERGED (Local)" \
+ --L3 "$MERGED (Remote)" \
+ -o "$MERGED" "$BASE" "$LOCAL" "$REMOTE" \
+ > /dev/null 2>&1)
+ else
+ ("$merge_tool_path" --auto \
+ --L1 "$MERGED (Local)" \
+ --L2 "$MERGED (Remote)" \
+ -o "$MERGED" "$LOCAL" "$REMOTE" \
+ > /dev/null 2>&1)
+ fi
+ status=$?
+ ;;
tkdiff)
- if base_present ; then
- "$merge_tool_path" -a "$BASE" -o "$MERGED" "$LOCAL" "$REMOTE"
- else
- "$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
- fi
- status=$?
- ;;
+ if base_present ; then
+ "$merge_tool_path" -a "$BASE" -o "$MERGED" "$LOCAL" "$REMOTE"
+ else
+ "$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
+ fi
+ status=$?
+ ;;
meld)
- touch "$BACKUP"
- "$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
- check_unchanged
- ;;
+ touch "$BACKUP"
+ "$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
+ check_unchanged
+ ;;
vimdiff)
- touch "$BACKUP"
- "$merge_tool_path" -c "wincmd l" "$LOCAL" "$MERGED" "$REMOTE"
- check_unchanged
- ;;
+ touch "$BACKUP"
+ "$merge_tool_path" -c "wincmd l" "$LOCAL" "$MERGED" "$REMOTE"
+ check_unchanged
+ ;;
gvimdiff)
- touch "$BACKUP"
- "$merge_tool_path" -c "wincmd l" -f "$LOCAL" "$MERGED" "$REMOTE"
- check_unchanged
- ;;
+ touch "$BACKUP"
+ "$merge_tool_path" -c "wincmd l" -f "$LOCAL" "$MERGED" "$REMOTE"
+ check_unchanged
+ ;;
xxdiff)
- touch "$BACKUP"
- if base_present ; then
- "$merge_tool_path" -X --show-merged-pane \
- -R 'Accel.SaveAsMerged: "Ctrl-S"' \
- -R 'Accel.Search: "Ctrl+F"' \
- -R 'Accel.SearchForward: "Ctrl-G"' \
- --merged-file "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
- else
- "$merge_tool_path" -X --show-merged-pane \
- -R 'Accel.SaveAsMerged: "Ctrl-S"' \
- -R 'Accel.Search: "Ctrl+F"' \
- -R 'Accel.SearchForward: "Ctrl-G"' \
- --merged-file "$MERGED" "$LOCAL" "$REMOTE"
- fi
- check_unchanged
- ;;
+ touch "$BACKUP"
+ if base_present ; then
+ "$merge_tool_path" -X --show-merged-pane \
+ -R 'Accel.SaveAsMerged: "Ctrl-S"' \
+ -R 'Accel.Search: "Ctrl+F"' \
+ -R 'Accel.SearchForward: "Ctrl-G"' \
+ --merged-file "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
+ else
+ "$merge_tool_path" -X --show-merged-pane \
+ -R 'Accel.SaveAsMerged: "Ctrl-S"' \
+ -R 'Accel.Search: "Ctrl+F"' \
+ -R 'Accel.SearchForward: "Ctrl-G"' \
+ --merged-file "$MERGED" "$LOCAL" "$REMOTE"
+ fi
+ check_unchanged
+ ;;
opendiff)
- touch "$BACKUP"
- if base_present; then
- "$merge_tool_path" "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED" | cat
- else
- "$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$MERGED" | cat
- fi
- check_unchanged
- ;;
+ touch "$BACKUP"
+ if base_present; then
+ "$merge_tool_path" "$LOCAL" "$REMOTE" \
+ -ancestor "$BASE" -merge "$MERGED" | cat
+ else
+ "$merge_tool_path" "$LOCAL" "$REMOTE" \
+ -merge "$MERGED" | cat
+ fi
+ check_unchanged
+ ;;
ecmerge)
- touch "$BACKUP"
- if base_present; then
- "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --default --mode=merge3 --to="$MERGED"
- else
- "$merge_tool_path" "$LOCAL" "$REMOTE" --default --mode=merge2 --to="$MERGED"
- fi
- check_unchanged
- ;;
+ touch "$BACKUP"
+ if base_present; then
+ "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" \
+ --default --mode=merge3 --to="$MERGED"
+ else
+ "$merge_tool_path" "$LOCAL" "$REMOTE" \
+ --default --mode=merge2 --to="$MERGED"
+ fi
+ check_unchanged
+ ;;
emerge)
- if base_present ; then
- "$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$MERGED")"
- else
- "$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$MERGED")"
- fi
- status=$?
- ;;
- *)
- if test -n "$merge_tool_cmd"; then
- if test "$merge_tool_trust_exit_code" = "false"; then
- touch "$BACKUP"
- ( eval $merge_tool_cmd )
- check_unchanged
+ if base_present ; then
+ "$merge_tool_path" -f emerge-files-with-ancestor-command \
+ "$LOCAL" "$REMOTE" "$BASE" "$(basename "$MERGED")"
else
- ( eval $merge_tool_cmd )
- status=$?
+ "$merge_tool_path" -f emerge-files-command \
+ "$LOCAL" "$REMOTE" "$(basename "$MERGED")"
fi
- fi
- ;;
- esac
- if test "$status" -ne 0; then
- echo "merge of $MERGED failed" 1>&2
- mv -- "$BACKUP" "$MERGED"
-
- if test "$merge_keep_temporaries" = "false"; then
- cleanup_temp_files
- fi
+ status=$?
+ ;;
+ *)
+ if test -n "$merge_tool_cmd"; then
+ if test "$merge_tool_trust_exit_code" = "false"; then
+ touch "$BACKUP"
+ ( eval $merge_tool_cmd )
+ check_unchanged
+ else
+ ( eval $merge_tool_cmd )
+ status=$?
+ fi
+ fi
+ ;;
+ esac
+ if test "$status" -ne 0; then
+ echo "merge of $MERGED failed" 1>&2
+ mv -- "$BACKUP" "$MERGED"
- return 1
- fi
+ if test "$merge_keep_temporaries" = "false"; then
+ cleanup_temp_files
+ fi
- if test "$merge_keep_backup" = "true"; then
- mv -- "$BACKUP" "$MERGED.orig"
- else
- rm -- "$BACKUP"
- fi
+ return 1
+ fi
+
+ if test "$merge_keep_backup" = "true"; then
+ mv -- "$BACKUP" "$MERGED.orig"
+ else
+ rm -- "$BACKUP"
+ fi
- git add -- "$MERGED"
- cleanup_temp_files
- return 0
+ git add -- "$MERGED"
+ cleanup_temp_files
+ return 0
}
prompt=$(git config --bool mergetool.prompt || echo true)
while test $# != 0
do
- case "$1" in
+ case "$1" in
-t|--tool*)
- case "$#,$1" in
+ case "$#,$1" in
*,*=*)
- merge_tool=`expr "z$1" : 'z-[^=]*=\(.*\)'`
- ;;
+ merge_tool=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+ ;;
1,*)
- usage ;;
+ usage ;;
*)
- merge_tool="$2"
- shift ;;
- esac
- ;;
+ merge_tool="$2"
+ shift ;;
+ esac
+ ;;
-y|--no-prompt)
- prompt=false
- ;;
+ prompt=false
+ ;;
--prompt)
- prompt=true
- ;;
+ prompt=true
+ ;;
--)
- shift
- break
- ;;
+ shift
+ break
+ ;;
-*)
- usage
- ;;
+ usage
+ ;;
*)
- break
- ;;
- esac
- shift
+ break
+ ;;
+ esac
+ shift
done
valid_custom_tool()
{
- merge_tool_cmd="$(git config mergetool.$1.cmd)"
- test -n "$merge_tool_cmd"
+ merge_tool_cmd="$(git config mergetool.$1.cmd)"
+ test -n "$merge_tool_cmd"
}
valid_tool() {
case "$1" in
- kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
+ kdiff3 | tkdiff | xxdiff | meld | opendiff | \
+ emerge | vimdiff | gvimdiff | ecmerge)
;; # happy
*)
if ! valid_custom_tool "$1"; then
@@ -370,117 +385,116 @@ init_merge_tool_path() {
}
prompt_after_failed_merge() {
- while true; do
- printf "Continue merging other unresolved paths (y/n) ? "
- read ans
- case "$ans" in
-
- [yY]*)
- return 0
- ;;
+ while true; do
+ printf "Continue merging other unresolved paths (y/n) ? "
+ read ans
+ case "$ans" in
+ [yY]*)
+ return 0
+ ;;
- [nN]*)
- return 1
- ;;
- esac
- done
+ [nN]*)
+ return 1
+ ;;
+ esac
+ done
}
if test -z "$merge_tool"; then
- merge_tool=`git config merge.tool`
- if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then
- echo >&2 "git config option merge.tool set to unknown tool: $merge_tool"
- echo >&2 "Resetting to default..."
- unset merge_tool
- fi
+ merge_tool=`git config merge.tool`
+ if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then
+ echo >&2 "git config option merge.tool set to unknown tool:" "$merge_tool"
+ echo >&2 "Resetting to default..."
+ unset merge_tool
+ fi
fi
if test -z "$merge_tool" ; then
- if test -n "$DISPLAY"; then
- if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
- merge_tool_candidates="meld kdiff3 tkdiff xxdiff gvimdiff"
- else
- merge_tool_candidates="kdiff3 tkdiff xxdiff meld gvimdiff"
- fi
- fi
- if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then
- merge_tool_candidates="$merge_tool_candidates emerge opendiff vimdiff"
- elif echo "${VISUAL:-$EDITOR}" | grep 'vim' > /dev/null 2>&1; then
- merge_tool_candidates="$merge_tool_candidates vimdiff opendiff emerge"
- else
- merge_tool_candidates="$merge_tool_candidates opendiff emerge vimdiff"
- fi
- echo "merge tool candidates: $merge_tool_candidates"
- for i in $merge_tool_candidates; do
- init_merge_tool_path $i
- if type "$merge_tool_path" > /dev/null 2>&1; then
- merge_tool=$i
- break
- fi
- done
- if test -z "$merge_tool" ; then
- echo "No known merge resolution program available."
- exit 1
- fi
+ if test -n "$DISPLAY"; then
+ if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
+ merge_tool_candidates="meld kdiff3 tkdiff xxdiff gvimdiff"
+ else
+ merge_tool_candidates="kdiff3 tkdiff xxdiff meld gvimdiff"
+ fi
+ fi
+ if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then
+ merge_tool_candidates="$merge_tool_candidates emerge opendiff vimdiff"
+ elif echo "${VISUAL:-$EDITOR}" | grep 'vim' > /dev/null 2>&1; then
+ merge_tool_candidates="$merge_tool_candidates vimdiff opendiff emerge"
+ else
+ merge_tool_candidates="$merge_tool_candidates opendiff emerge vimdiff"
+ fi
+ echo "merge tool candidates: $merge_tool_candidates"
+ for i in $merge_tool_candidates; do
+ init_merge_tool_path $i
+ if type "$merge_tool_path" > /dev/null 2>&1; then
+ merge_tool=$i
+ break
+ fi
+ done
+ if test -z "$merge_tool" ; then
+ echo "No known merge resolution program available."
+ exit 1
+ fi
else
- if ! valid_tool "$merge_tool"; then
- echo >&2 "Unknown merge_tool $merge_tool"
- exit 1
- fi
+ if ! valid_tool "$merge_tool"; then
+ echo >&2 "Unknown merge_tool $merge_tool"
+ exit 1
+ fi
- init_merge_tool_path "$merge_tool"
+ init_merge_tool_path "$merge_tool"
- merge_keep_backup="$(git config --bool merge.keepBackup || echo true)"
- merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
+ merge_keep_backup="$(git config --bool merge.keepBackup || echo true)"
+ merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
- if test -z "$merge_tool_cmd" && ! type "$merge_tool_path" > /dev/null 2>&1; then
- echo "The merge tool $merge_tool is not available as '$merge_tool_path'"
- exit 1
- fi
+ if test -z "$merge_tool_cmd" && ! type "$merge_tool_path" > /dev/null 2>&1; then
+ echo "The merge tool $merge_tool is not available as '$merge_tool_path'"
+ exit 1
+ fi
- if ! test -z "$merge_tool_cmd"; then
- merge_tool_trust_exit_code="$(git config --bool mergetool.$merge_tool.trustExitCode || echo false)"
- fi
+ if ! test -z "$merge_tool_cmd"; then
+ merge_tool_trust_exit_code="$(git config --bool mergetool.$merge_tool.trustExitCode || echo false)"
+ fi
fi
last_status=0
rollup_status=0
if test $# -eq 0 ; then
- files=`git ls-files -u | sed -e 's/^[^ ]* //' | sort -u`
- if test -z "$files" ; then
- echo "No files need merging"
- exit 0
- fi
- echo Merging the files: "$files"
- git ls-files -u |
- sed -e 's/^[^ ]* //' |
- sort -u |
- while IFS= read i
- do
- if test $last_status -ne 0; then
- prompt_after_failed_merge < /dev/tty || exit 1
+ files=`git ls-files -u | sed -e 's/^[^ ]* //' | sort -u`
+ if test -z "$files" ; then
+ echo "No files need merging"
+ exit 0
fi
- printf "\n"
- merge_file "$i" < /dev/tty > /dev/tty
- last_status=$?
- if test $last_status -ne 0; then
- rollup_status=1
- fi
- done
+ echo Merging the files: "$files"
+ git ls-files -u |
+ sed -e 's/^[^ ]* //' |
+ sort -u |
+ while IFS= read i
+ do
+ if test $last_status -ne 0; then
+ prompt_after_failed_merge < /dev/tty || exit 1
+ fi
+ printf "\n"
+ merge_file "$i" < /dev/tty > /dev/tty
+ last_status=$?
+ if test $last_status -ne 0; then
+ rollup_status=1
+ fi
+ done
else
- while test $# -gt 0; do
- if test $last_status -ne 0; then
- prompt_after_failed_merge || exit 1
- fi
- printf "\n"
- merge_file "$1"
- last_status=$?
- if test $last_status -ne 0; then
- rollup_status=1
- fi
- shift
- done
+ while test $# -gt 0; do
+ if test $last_status -ne 0; then
+ prompt_after_failed_merge || exit 1
+ fi
+ printf "\n"
+ merge_file "$1"
+ last_status=$?
+ if test $last_status -ne 0; then
+ rollup_status=1
+ fi
+ shift
+ done
fi
exit $rollup_status
--
1.6.1.3
^ permalink raw reply related
* [PATCH 2/8] mergetool: use $( ... ) instead of `backticks`
From: David Aguilar @ 2009-03-30 5:03 UTC (permalink / raw)
To: gitster; +Cc: git, David Aguilar
In-Reply-To: <1238389428-69328-2-git-send-email-davvid@gmail.com>
This makes mergetool consistent with Documentation/CodingGuidelines.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-mergetool.sh | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index cfee28e..5ea126c 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -138,7 +138,7 @@ checkout_staged_file () {
merge_file () {
MERGED="$1"
- f=`git ls-files -u -- "$MERGED"`
+ f=$(git ls-files -u -- "$MERGED")
if test -z "$f" ; then
if test ! -f "$MERGED" ; then
echo "$MERGED: file not found"
@@ -157,9 +157,9 @@ merge_file () {
mv -- "$MERGED" "$BACKUP"
cp -- "$BACKUP" "$MERGED"
- base_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}'`
- local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
- remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
+ base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
+ local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')
+ remote_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}')
base_present && checkout_staged_file 1 "$MERGED" "$BASE"
local_present && checkout_staged_file 2 "$MERGED" "$LOCAL"
@@ -322,7 +322,7 @@ do
-t|--tool*)
case "$#,$1" in
*,*=*)
- merge_tool=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+ merge_tool=$(expr "z$1" : 'z-[^=]*=\(.*\)')
;;
1,*)
usage ;;
@@ -371,7 +371,7 @@ valid_tool() {
}
init_merge_tool_path() {
- merge_tool_path=`git config mergetool.$1.path`
+ merge_tool_path=$(git config mergetool.$1.path)
if test -z "$merge_tool_path" ; then
case "$1" in
emerge)
@@ -401,7 +401,7 @@ prompt_after_failed_merge() {
}
if test -z "$merge_tool"; then
- merge_tool=`git config merge.tool`
+ merge_tool=$(git config merge.tool)
if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then
echo >&2 "git config option merge.tool set to unknown tool:" "$merge_tool"
echo >&2 "Resetting to default..."
@@ -461,7 +461,7 @@ last_status=0
rollup_status=0
if test $# -eq 0 ; then
- files=`git ls-files -u | sed -e 's/^[^ ]* //' | sort -u`
+ files=$(git ls-files -u | sed -e 's/^[^ ]* //' | sort -u)
if test -z "$files" ; then
echo "No files need merging"
exit 0
--
1.6.1.3
^ permalink raw reply related
* (unknown),
From: David Aguilar @ 2009-03-30 5:03 UTC (permalink / raw)
To: gitster; +Cc: git
As promised, here is the patch series that removes the duplicate
code between git-difftool and git-mergetool.
This is based on top of Junio's "pu" branch and is a
continuation of the recent difftool series.
I created a new git-sh-tools shell lib for holding the
common functions. If anyone thinks I should have placed the
functions in git-sh-setup instead then just let me know.
Here's a total diffstat. If it wasn't for the documentation
and replacing the mixed spaces/tabs with all-tabs in
git-mergetool then we would have seen a lot more
happy removals.
.gitignore | 1 +
Documentation/git-sh-tools.txt | 52 ++++
Makefile | 1 +
command-list.txt | 1 +
git-difftool-helper.sh | 112 +-------
git-mergetool.sh | 639 ++++++++++++++++------------------------
git-sh-tools.sh | 181 ++++++++++++
7 files changed, 506 insertions(+), 481 deletions(-)
GIT:
From: David Aguilar <davvid@gmail.com>
Subject: Refactor git-{diff,merge}tool to remove duplicate code
In-Reply-To:
^ permalink raw reply
* [PATCH 2/2] bisect--helper: string output variables together with "&&"
From: Christian Couder @ 2009-03-30 4:59 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell, Johannes Schindelin
When doing:
eval "git bisect--helper --next-vars" | {
while read line
do
echo "$line &&"
done
echo ':'
}
the result code comes from the last "echo ':'", not from running
"git bisect--helper --next-vars".
This patch get rid of the need to string the line from the output
of "git bisect--helper" by making "git bisect--helper --next-vars"
return output variables stringed together with "&&".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
bisect.c | 3 ++-
bisect.h | 1 +
builtin-rev-list.c | 29 +++++++++++++++++++----------
git-bisect.sh | 15 +--------------
4 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/bisect.c b/bisect.c
index 64a5ad5..df0ab4d 100644
--- a/bisect.c
+++ b/bisect.c
@@ -554,5 +554,6 @@ int bisect_next_vars(const char *prefix)
revs.commits = find_bisection(revs.commits, &reaches, &all,
!!skipped_sha1_nr);
- return show_bisect_vars(&revs, reaches, all, SHOW_TRIED);
+ return show_bisect_vars(&revs, reaches, all,
+ SHOW_TRIED | SHOW_STRINGED);
}
diff --git a/bisect.h b/bisect.h
index 4cff2ba..2e4b2af 100644
--- a/bisect.h
+++ b/bisect.h
@@ -12,6 +12,7 @@ extern struct commit_list *filter_skipped(struct commit_list *list,
/* show_bisect_vars flags */
#define SHOW_ALL 1
#define SHOW_TRIED 2
+#define SHOW_STRINGED 4
/*
* The flag SHOW_ALL should not be set if this function is called
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index c1c4a18..330f7f0 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -226,20 +226,20 @@ static int estimate_bisect_steps(int all)
return (e < 3 * x) ? n : n - 1;
}
-static void show_tried_revs(struct commit_list *tried)
+static void show_tried_revs(struct commit_list *tried, int stringed)
{
printf("bisect_tried='");
for (;tried; tried = tried->next) {
char *format = tried->next ? "%s|" : "%s";
printf(format, sha1_to_hex(tried->item->object.sha1));
}
- printf("'\n");
+ printf(stringed ? "' &&\n" : "'\n");
}
int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
{
int cnt;
- char hex[41] = "";
+ char hex[41] = "", *format;
struct commit_list *tried;
if (!revs->commits && !(flags & SHOW_TRIED))
@@ -269,13 +269,22 @@ int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
}
if (flags & SHOW_TRIED)
- show_tried_revs(tried);
- printf("bisect_rev=%s\n"
- "bisect_nr=%d\n"
- "bisect_good=%d\n"
- "bisect_bad=%d\n"
- "bisect_all=%d\n"
- "bisect_steps=%d\n",
+ show_tried_revs(tried, flags & SHOW_STRINGED);
+ format = (flags & SHOW_STRINGED) ?
+ "bisect_rev=%s &&\n"
+ "bisect_nr=%d &&\n"
+ "bisect_good=%d &&\n"
+ "bisect_bad=%d &&\n"
+ "bisect_all=%d &&\n"
+ "bisect_steps=%d\n"
+ :
+ "bisect_rev=%s\n"
+ "bisect_nr=%d\n"
+ "bisect_good=%d\n"
+ "bisect_bad=%d\n"
+ "bisect_all=%d\n"
+ "bisect_steps=%d\n";
+ printf(format,
hex,
cnt - 1,
all - reaches - 1,
diff --git a/git-bisect.sh b/git-bisect.sh
index 0f7590d..5074dda 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -279,18 +279,6 @@ bisect_auto_next() {
bisect_next_check && bisect_next || :
}
-eval_and_string_together() {
- _eval="$1"
-
- eval "$_eval" | {
- while read line
- do
- echo "$line &&"
- done
- echo ':'
- }
-}
-
exit_if_skipped_commits () {
_tried=$1
_bad=$2
@@ -429,8 +417,7 @@ bisect_next() {
test "$?" -eq "1" && return
# Get bisection information
- eval="git bisect--helper --next-vars" &&
- eval=$(eval_and_string_together "$eval") &&
+ eval=$(eval "git bisect--helper --next-vars") &&
eval "$eval" || exit
if [ -z "$bisect_rev" ]; then
--
1.6.2.1.404.gb0085.dirty
^ permalink raw reply related
* [PATCH v2 1/2] rev-list: pass a flag as last argument of "show_bisect_vars"
From: Christian Couder @ 2009-03-30 4:59 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell, Johannes Schindelin
Instead of "int show_all, int show_tried" we now only pass "int flags",
because we will add more flags in a later patch.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
bisect.c | 2 +-
bisect.h | 8 ++++++--
builtin-rev-list.c | 13 ++++++-------
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/bisect.c b/bisect.c
index 66df05f..64a5ad5 100644
--- a/bisect.c
+++ b/bisect.c
@@ -554,5 +554,5 @@ int bisect_next_vars(const char *prefix)
revs.commits = find_bisection(revs.commits, &reaches, &all,
!!skipped_sha1_nr);
- return show_bisect_vars(&revs, reaches, all, 0, 1);
+ return show_bisect_vars(&revs, reaches, all, SHOW_TRIED);
}
diff --git a/bisect.h b/bisect.h
index 05eea17..4cff2ba 100644
--- a/bisect.h
+++ b/bisect.h
@@ -9,13 +9,17 @@ extern struct commit_list *filter_skipped(struct commit_list *list,
struct commit_list **tried,
int show_all);
+/* show_bisect_vars flags */
+#define SHOW_ALL 1
+#define SHOW_TRIED 2
+
/*
- * The "show_all" parameter should be 0 if this function is called
+ * The flag SHOW_ALL should not be set if this function is called
* from outside "builtin-rev-list.c" as otherwise it would use
* static "revs" from this file.
*/
extern int show_bisect_vars(struct rev_info *revs, int reaches, int all,
- int show_all, int show_tried);
+ int flags);
extern int bisect_next_vars(const char *prefix);
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 925d643..c1c4a18 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -236,17 +236,16 @@ static void show_tried_revs(struct commit_list *tried)
printf("'\n");
}
-int show_bisect_vars(struct rev_info *revs, int reaches, int all,
- int show_all, int show_tried)
+int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
{
int cnt;
char hex[41] = "";
struct commit_list *tried;
- if (!revs->commits && !show_tried)
+ if (!revs->commits && !(flags & SHOW_TRIED))
return 1;
- revs->commits = filter_skipped(revs->commits, &tried, show_all);
+ revs->commits = filter_skipped(revs->commits, &tried, flags & SHOW_ALL);
/*
* revs->commits can reach "reaches" commits among
@@ -264,12 +263,12 @@ int show_bisect_vars(struct rev_info *revs, int reaches, int all,
if (revs->commits)
strcpy(hex, sha1_to_hex(revs->commits->item->object.sha1));
- if (show_all) {
+ if (flags & SHOW_ALL) {
traverse_commit_list(revs, show_commit, show_object);
printf("------\n");
}
- if (show_tried)
+ if (flags & SHOW_TRIED)
show_tried_revs(tried);
printf("bisect_rev=%s\n"
"bisect_nr=%d\n"
@@ -379,7 +378,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
if (bisect_show_vars)
return show_bisect_vars(&revs, reaches, all,
- bisect_show_all, 0);
+ bisect_show_all ? SHOW_ALL : 0);
}
traverse_commit_list(&revs,
--
1.6.2.1.404.gb0085.dirty
^ 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