Git development
 help / color / mirror / Atom feed
* Re: [PATCH 1/2] user-manual: Simplify the user configuration.
From: Felipe Contreras @ 2009-01-22 16:57 UTC (permalink / raw)
  To: Hannu Koivisto; +Cc: Junio C Hamano, git
In-Reply-To: <831vuvfh7t.fsf@kalahari.s2.org>

On Thu, Jan 22, 2009 at 6:17 PM, Hannu Koivisto <azure@iki.fi> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> This brings back my previous question: where is the home directory in
>> a Windows system?
>
> It's where %HOMEDRIVE%%HOMEPATH% points to.

I thought it was something like that. Do we want something like that
in the manual, or should we assume Windows users know that?

-- 
Felipe Contreras

^ permalink raw reply

* Re: [PATCH 1/2] user-manual: Simplify the user configuration.
From: Junio C Hamano @ 2009-01-22 17:14 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Hannu Koivisto, git
In-Reply-To: <94a0d4530901220857q1027c05bs137dcc0244a1cc5a@mail.gmail.com>

Felipe Contreras <felipe.contreras@gmail.com> writes:

> On Thu, Jan 22, 2009 at 6:17 PM, Hannu Koivisto <azure@iki.fi> wrote:
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>> This brings back my previous question: where is the home directory in
>>> a Windows system?
>>
>> It's where %HOMEDRIVE%%HOMEPATH% points to.
>
> I thought it was something like that. Do we want something like that
> in the manual, or should we assume Windows users know that?

Funny; while I was test driving Msysgit (I wrote the report in my blog
pages some time ago), I got curious about this exact issue.  I thought the
choice of $HOME at that path was quite natural even for me who does not
usually use Windows.

^ permalink raw reply

* [PATCH] cygwin: Convert paths for html help from posix to windows
From: Björn Steinbrink @ 2009-01-22 17:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: jaeckel, git

When using "git help --web" with cygwin, we used to pass the posix path
to the browser, but a native windows browser will expect a windows path
and is unable to make use of the given path.

So the cygwin port gets its own open_html implementation that handles
the path conversion.

Reported-by: Steffen Jaeckel <jaeckel@stzedn.de>
Tested-by: Steffen Jaeckel <jaeckel@stzedn.de>

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
---
OK, I don't really know if this is the right way to do it. Maybe when
the browser was built for cygwin this breaks? I have no clue, it's
admittedly just the result of a quick glance at the code and some
googling to find the "right" cygwin function... :-/

 compat/cygwin.c |    7 +++++++
 compat/cygwin.h |    3 +++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/compat/cygwin.c b/compat/cygwin.c
index ebac148..70ecd2d 100644
--- a/compat/cygwin.c
+++ b/compat/cygwin.c
@@ -141,3 +141,10 @@ static int cygwin_lstat_stub(const char *file_name, struct stat *buf)
 stat_fn_t cygwin_stat_fn = cygwin_stat_stub;
 stat_fn_t cygwin_lstat_fn = cygwin_lstat_stub;
 
+void cygwin_open_html(const char *unixpath)
+{
+	char cygpath[PATH_MAX];
+
+	cygwin_conv_to_win32_path(unixpath, cygpath);
+	execl_git_cmd("web--browse", "-c", "help.browser", cygpath, NULL);
+}
diff --git a/compat/cygwin.h b/compat/cygwin.h
index a3229f5..7cbefea 100644
--- a/compat/cygwin.h
+++ b/compat/cygwin.h
@@ -7,3 +7,6 @@ extern stat_fn_t cygwin_lstat_fn;
 
 #define stat(path, buf) (*cygwin_stat_fn)(path, buf)
 #define lstat(path, buf) (*cygwin_lstat_fn)(path, buf)
+
+void cygwin_open_html(const char *path);
+#define open_html cygwin_open_html
-- 
1.6.1.230.gf873d

^ permalink raw reply related

* Re: [PATCH] Add --contains flag to git tag
From: Junio C Hamano @ 2009-01-22 17:17 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Jake Goulding, git
In-Reply-To: <20090121032058.GG21473@genesis.frugalware.org>

Miklos Vajna <vmiklos@frugalware.org> writes:

> On Tue, Jan 20, 2009 at 08:37:09PM -0500, Jake Goulding <goulding@vivisimo.com> wrote:
>> Please let me know what else I have inevitably messed up, and I shall
>> endeavor to fix and resubmit. 
>
> Please document your improvements in Documentation/git-tag.txt and don't
> forget to add a testcase to t7004-tag.sh.

Thanks for saving me time ;-)

^ permalink raw reply

* Re: [PATCH] cygwin: Convert paths for html help from posix to windows
From: Junio C Hamano @ 2009-01-22 17:25 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: jaeckel, git
In-Reply-To: <20090122171605.GA16684@atjola.homenet>

Björn Steinbrink <B.Steinbrink@gmx.de> writes:

> OK, I don't really know if this is the right way to do it. Maybe when
> the browser was built for cygwin this breaks? I have no clue,...

It might be simple enough to check if all it takes is to install a
prepackaged browser from Cygwin suite and try to run it.  Doesn't Cygwin
have small ones such as lynx (or links)?

^ permalink raw reply

* Re: [PATCH 1/2] user-manual: Simplify the user configuration.
From: Johannes Schindelin @ 2009-01-22 17:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Felipe Contreras, Hannu Koivisto, git
In-Reply-To: <7v1vuv8dqy.fsf@gitster.siamese.dyndns.org>

Hi,

On Thu, 22 Jan 2009, Junio C Hamano wrote:

> Felipe Contreras <felipe.contreras@gmail.com> writes:
> 
> > On Thu, Jan 22, 2009 at 6:17 PM, Hannu Koivisto <azure@iki.fi> wrote:
> >> Felipe Contreras <felipe.contreras@gmail.com> writes:
> >>
> >>> This brings back my previous question: where is the home directory in
> >>> a Windows system?
> >>
> >> It's where %HOMEDRIVE%%HOMEPATH% points to.
> >
> > I thought it was something like that. Do we want something like that
> > in the manual, or should we assume Windows users know that?
> 
> Funny; while I was test driving Msysgit (I wrote the report in my blog
> pages some time ago), I got curious about this exact issue.  I thought the
> choice of $HOME at that path was quite natural even for me who does not
> usually use Windows.

That's what they said when they convinced me that /home/<user>/ was not a 
natural place on Windows.

Ciao,
Dscho

^ permalink raw reply

* Re: [PATCH 2/2] git-log: Follow file copies with 'git log --follow -C -C'
From: Junio C Hamano @ 2009-01-22 17:28 UTC (permalink / raw)
  To: Arjen Laarhoven; +Cc: git
In-Reply-To: <1232642245-94405-2-git-send-email-arjen@yaph.org>

Arjen Laarhoven <arjen@yaph.org> writes:

> When the '--follow' option is used with '--find-copies-harder' ('-C -C')
> logs on individual files will work across file copies as well as
> renames.

Is there a reason to limit this to "harder" case?

> diff --git a/tree-diff.c b/tree-diff.c
> index 9f67af6..73652b2 100644
> --- a/tree-diff.c
> +++ b/tree-diff.c
> @@ -333,6 +333,8 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
>  
>  	diff_setup(&diff_opts);
>  	DIFF_OPT_SET(&diff_opts, RECURSIVE);
> +	if (DIFF_OPT_TST(opt, FIND_COPIES_HARDER))
> +		DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
>  	diff_opts.detect_rename = DIFF_DETECT_RENAME;

Hmm, why isn't this DIFF_DETECT_COPY?

>  	diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
>  	diff_opts.single_follow = opt->paths[0];
> -- 
> 1.6.1.354.gd9e51

^ permalink raw reply

* Re: [PATCH] cygwin: Convert paths for html help from posix to windows
From: Johannes Schindelin @ 2009-01-22 17:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Björn Steinbrink, jaeckel, git
In-Reply-To: <7veiyv6ynm.fsf@gitster.siamese.dyndns.org>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 564 bytes --]

Hi,

On Thu, 22 Jan 2009, Junio C Hamano wrote:

> Björn Steinbrink <B.Steinbrink@gmx.de> writes:
> 
> > OK, I don't really know if this is the right way to do it. Maybe when
> > the browser was built for cygwin this breaks? I have no clue,...
> 
> It might be simple enough to check if all it takes is to install a
> prepackaged browser from Cygwin suite and try to run it.  Doesn't Cygwin
> have small ones such as lynx (or links)?

Was it not the case that Cygwin programs could grok Windows paths, too?  
IIRC w3m is available, dunno about lynx.

Ciao,
Dscho

^ permalink raw reply

* How to prefix existing svn remotes?
From: Sébastien Mazy @ 2009-01-22 17:32 UTC (permalink / raw)
  To: git

Hi all,


I created a few months ago a git-svn repository using:
git svn clone -s https://my_svn_repo .

wich also created the following remotes:
git branch -r
  branch0
  tags/tag0
  trunk

I would like to prefix theses remotes, so that it shows:
git branch -r
  prefix/branch0
  prefix/tags/tag0
  prefix/trunk

Of course I should have used the -prefix back when creating the repo but
it's too late. 'git help svn' doesn't explain how to achieve that and
simply editing .git/config to add the missing prefix will cause the next
'git svn fetch' to download again the whole history (which in my case is
huge).


Is it possible? Did I miss something obvious?


Cheers,

-- 
Sébastien Mazy

^ permalink raw reply

* Re: [PATCH 1/2] user-manual: Simplify the user configuration.
From: Hannu Koivisto @ 2009-01-22 18:59 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Junio C Hamano, git, Johannes Schindelin
In-Reply-To: <94a0d4530901220857q1027c05bs137dcc0244a1cc5a@mail.gmail.com>

Felipe Contreras <felipe.contreras@gmail.com> writes:

> On Thu, Jan 22, 2009 at 6:17 PM, Hannu Koivisto <azure@iki.fi> wrote:
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>> This brings back my previous question: where is the home directory in
>>> a Windows system?
>>
>> It's where %HOMEDRIVE%%HOMEPATH% points to.
>
> I thought it was something like that. Do we want something like that
> in the manual, or should we assume Windows users know that?

I should have added that Unix programs (i.e. Cygwin programs and
even some native ports) probably use %HOME% which may be different
from %HOMEDRIVE%%HOMEPATH%.  I recall that if you haven't
explicitly set up HOME in Windows environment, Cygwin sets it up
magically from passwd or falls back to %HOMEDRIVE%%HOMEPATH%.  I
have no idea if msysgit respects %HOME% if it is set or always uses
%HOMEDRIVE%%HOMEPATH% or something completely different (user
profile, most likely).

It certainly may be that "home directory" is a foreign concept to
some Windows users.  Some might know it as a user profile or a
personal folder (just guessing, I'm pretty isolated from less
experienced Windows users), even though user profile is a separate
concept from "home directory" (note that there is %USERPROFILE%
which by default is the same as %HOMEDRIVE%%HOMEPATH% at least in
XP).

In any case, what Cygwin git does should be expected by Cygwin
users.  If msysgit wanted to be a really native Windows application
and store the configuration where Microsoft thinks it should be
stored, it probably shouldn't store the config under "home
directory" to begin with (I'm guessing that's what it does) but
under %USERPROFILE\Application Data\Git (...FILE\Local
Settings\... in case non-roaming storage is wanted).  And in that
case the manual might be misleading for msysgit users.  See
e.g. <http://msdn.microsoft.com/en-us/library/ms995853.aspx>.

-- 
Hannu

^ permalink raw reply

* Re[2]: [PATCH] cygwin: Convert paths for html help from posix to windows
From: Steffen Jaeckel @ 2009-01-22 19:34 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, Björn Steinbrink, git
In-Reply-To: <alpine.DEB.1.00.0901221829180.3586@pacific.mpi-cbg.de>

Hi,

-----Original Message-----
From: Johannes Schindelin [mailto:Johannes.Schindelin@gmx.de] 

> Hi,

> On Thu, 22 Jan 2009, Junio C Hamano wrote:

>> Björn Steinbrink <B.Steinbrink@gmx.de> writes:
>> 
>> > OK, I don't really know if this is the right way to do it. Maybe when
>> > the browser was built for cygwin this breaks? I have no clue,...
>> 
>> It might be simple enough to check if all it takes is to install a
>> prepackaged browser from Cygwin suite and try to run it.  Doesn't Cygwin
>> have small ones such as lynx (or links)?

> Was it not the case that Cygwin programs could grok Windows paths, too?  
> IIRC w3m is available, dunno about lynx.

> Ciao,
> Dscho

The intention of this patch was to hand over the url to a windows
application.

In cygwin you can use lynx, links and others, but they are not as
smart to use as a browser with a real gui.

Cygwin can't handle windows paths, and this patch will break
cygwin based browsers like links...

My first idea was to patch the git-web--browse.sh script in the section
where the browser is called.
--------
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 78d236b..f726f8f 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -143,7 +143,7 @@ case "$browser" in
        vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
        NEWTAB='-new-tab'
        test "$vers" -lt 2 && NEWTAB=''
-       "$browser_path" $NEWTAB "$@" &
+       "$browser_path" $NEWTAB "`cygpath -w $@`" &
        ;;
     konqueror)
        case "$(basename "$browser_path")" in
--------
This solution works for cygwin internal browsers where the posix path
is required and it works for windows apps called out of the cygwin
environment as well.
This is certainely not a proper solution but I've got no other idea
how to solve the problem.

Best regards,
steffen
-- 
Steffen Jaeckel
Steinbeis-Transferzentrum/Steinbeis-Innovationszentrum 
Embedded Design und Networking
an der Berufsakademie Lörrach
Poststraße 35, 79423 Heitersheim
Leiter: Prof. Dr.-Ing. Axel Sikora
Phone: +49 7634 6949341
Mob  : +49  170 2328968
Fax  : +49 7634 5049886
www.stzedn.de

HINWEIS
Das Steinbeis Transferzentrum Embedded Design und Networking (stzedn)
an der Dualen Hochschule Baden-Württemberg/Berufsakademie Lörrach wird
vom 3.-5.3.2009 auf der Embedded World 2009 in Nürnberg mit einem Stand
vertreten sein. Bitte besuchen Sie uns in Halle 12 Stand 322h.

Zentrale: 
Steinbeis GmbH & Co. KG für Technologietransfer 
Willi-Bleicher-Straße 19, 70174 Stuttgart 
Registergericht Stuttgart HRA 12 480 

Komplementär: Steinbeis-Verwaltung-GmbH, Registergericht Stuttgart HRB 18715 
Geschäftsführer: Prof. Dr. Heinz Trasch, Prof. Dr. Michael Auer 

Der Inhalt dieser E-Mail einschließlich aller Anhänge ist vertraulich und 
ausschließlich für den bezeichneten Adressaten bestimmt. Wenn Sie nicht der 
vorgesehene Adressat dieser E-Mail oder dessen Vertreter sein sollten, so 
beachten Sie bitte, dass jede Form der Kenntnisnahme, Veröffentlichung, 
Vervielfältigung oder Weitergabe des Inhalts dieser E-Mail unzulässig ist. 
Wir bitten Sie, sich in diesem Fall mit dem Absender der E-Mail in Verbindung 
zu setzen, sowie die Originalnachricht zu löschen und alle Kopien hiervon zu 
vernichten.

This e-mail message including any attachments is for the sole use of the 
intended recipient(s) and may contain privileged or confidential information. 
Any unauthorized review, use, disclosure or distribution is prohibited. If you 
are not the intended recipient, please immediately contact the sender by reply 
e-mail and delete the original message and destroy all copies thereof.

^ permalink raw reply related

* [PATCH] Fix Documentation for git-describe
From: Boyd Stephen Smith Jr. @ 2009-01-22 18:26 UTC (permalink / raw)
  To: Tomas Carnecky; +Cc: Martin Pirker, git, Junio C Hamano
In-Reply-To: <497867BE.8070509@dbservice.com>

The documentation for git-describe says the default abbreviation is 8
hexadecimal digits while cache.c clearly shows DEFAULT_ABBREV set to 7.
This patch corrects the documentation.

Signed-off-by: Boyd Stephen Smith Jr <bss@iguanasuicide.net>
---
On Thursday 2009 January 22 06:34:06 Tomas Carnecky wrote:
>On 01/22/2009 12:26 PM, Martin Pirker wrote:
>> john@doe:/workspace$ git version
>> git version 1.6.1
>> john@doe:/workspace$ git describe
>> fatal: cannot describe '7aee61cc635a923e70b74091486742481ee0928b'
>> john@doe:/workspace$ git describe --always
>> 7aee61c
>> john@doe:/workspace$ git describe --always --abbrev=8
>> 7aee61cc
>>
>> man git-describe:
>>    --abbrev=<n>
>>        Instead of using the default 8 hexadecimal digits as the
>>        abbreviated object name, use<n>  digits.
>>
>> There is one character missing from default or what am I missing?
>
>The man page is wrong:
>
>cache.h:#define DEFAULT_ABBREV 7
>builtin-describe.c:static int abbrev = DEFAULT_ABBREV;

Let's fix it then!  This is a patch against maint.

Is there any way to include values from the source as text in the ascidoc
other than copy-and-paste?  It would be nice if we don't have to do this fix
again in the future.

I did a quick scan of 'git grep 8 -- Documentation' and didn't see
anywhere else this needed fixing.

 Documentation/git-describe.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
index 3d79f05..a30c5ac 100644
--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -43,7 +43,7 @@ OPTIONS
 	Automatically implies --tags.
 
 --abbrev=<n>::
-	Instead of using the default 8 hexadecimal digits as the
+	Instead of using the default 7 hexadecimal digits as the
 	abbreviated object name, use <n> digits.
 
 --candidates=<n>::
-- 
1.6.0.2
-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     

^ permalink raw reply related

* Re: Merging adjacent deleted lines?
From: Robin Rosenberg @ 2009-01-22 20:13 UTC (permalink / raw)
  To: Jonathan del Strother; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <57518fd10901220257p62b6d1efof97ba3fcf90dbfda@mail.gmail.com>

torsdag 22 januari 2009 11:57:41 skrev Jonathan del Strother:
> On Wed, Jan 21, 2009 at 7:49 PM, Robin Rosenberg
> <robin.rosenberg.lists@dewire.com> wrote:
> > onsdag 21 januari 2009 20:20:50 skrev Jonathan del Strother:
> > [...]
> > I think you've illustrated a case for graphical merge resolution tools, i.e.
> > run git mergetool to help resolve the conlicts. It will run a graphical tool
> > for you.
> >
> 
> Mmm.  I use opendiff, which is generally ok, but in this case produced
> a merge looking like this :
> http://pastie.org/paste/asset/367587/Picture_6.png
> Which, in my mind, isn't any clearer about the fact that both lines
> ought to be deleted than the text conflict markers are.  Do any of the
> other graphical tools present conflicts like that differently?

Try a three-way merge tool instead like, e.g. xxdiff.

-- robin

^ permalink raw reply

* Git Extensions video tutorials
From: Henk @ 2009-01-22 20:26 UTC (permalink / raw)
  To: git


I uploaded some videos to YouTube that show how to perform some basic Git
actions using Git Extensions. All video's are captured from screen without
any editing, so I hope they are any good. I tried to zoom in as much as
possible to compensate for the low quality on YouTube.

http://www.youtube.com/watch?v=TlZXSkJGKF8 1. Clone repository 
http://www.youtube.com/watch?v=B8uvje6X7lo 2. Commit changes 
http://www.youtube.com/watch?v=JByfXdbVAiE 3. Push changes 
http://www.youtube.com/watch?v=9g8gXPsi5Ko 4. Pull Changes 
http://www.youtube.com/watch?v=Kmc39RvuGM8 5. Handle mergeconflicts 
-- 
View this message in context: http://n2.nabble.com/Git-Extensions-video-tutorials-tp2199944p2199944.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply

* Re: Git Extensions video tutorials
From: Sverre Rabbelier @ 2009-01-22 21:00 UTC (permalink / raw)
  To: Henk; +Cc: git
In-Reply-To: <1232655984838-2199944.post@n2.nabble.com>

Heya,

On Thu, Jan 22, 2009 at 21:26, Henk <henk_westhuis@hotmail.com> wrote:
> I uploaded some videos to YouTube that show how to perform some basic Git
> actions using Git Extensions. All video's are captured from screen without
> any editing, so I hope they are any good. I tried to zoom in as much as
> possible to compensate for the low quality on YouTube.

Looks nice, seems like a git client that even a designer might be able
to use. The VS integration is nice as well (for those that use it).
It seems though, that you follow the svn paradigm "do not ever allow
the user to cancel what they're doing" even more rigoriously by simply
not providing a "cancel" button in the first place (as opposed to
svn's cancel button that takes about as long to actually do something
as it would have taken for the command to finish).

-- 
Cheers,

Sverre Rabbelier

^ permalink raw reply

* [RFC/PATCH v3 0/3] Add support for `git archive --submodules`
From: Lars Hjemli @ 2009-01-22 21:17 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin, René Scharfe

This series teaches read_tree_recursive() how to traverse gitlink entries
when explicitly instructed to do so (by the return value from the provided
callback function) and then uses this functionallity in git-archive to
implement a basic --submodules option (as suggested by René in
http://thread.gmane.org/gmane.comp.version-control.git/106167/focus=106235).

The commit message of the third patch has some suggestions on how the new
feature may be extended to support more use cases - hopefully this will
cover the issues mentioned by Johannes and Junio in the same thread.

Lars Hjemli (3):
  tree.c: teach read_tree_recursive how to traverse gitlink entries
  sha1_file: prepare for adding alternates on demand
  archive.c: add basic support for submodules

 Documentation/git-archive.txt |    3 +
 archive.c                     |   53 ++++++++++++++++++-
 archive.h                     |    1 +
 builtin-ls-tree.c             |    9 +---
 cache.h                       |    1 +
 merge-recursive.c             |    2 +-
 sha1_file.c                   |   40 +++++++++-----
 t/t5001-archive-submodules.sh |  121 +++++++++++++++++++++++++++++++++++++++++
 tree.c                        |   28 ++++++++++
 9 files changed, 236 insertions(+), 22 deletions(-)
 create mode 100755 t/t5001-archive-submodules.sh

^ permalink raw reply

* [RFC/PATCH v3 1/3] tree.c: teach read_tree_recursive how to traverse gitlink entries
From: Lars Hjemli @ 2009-01-22 21:17 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin, René Scharfe
In-Reply-To: <1232659071-14401-1-git-send-email-hjemli@gmail.com>

When the callback function invoked from read_tree_recursive() returns
`READ_TREE_RECURSIVE` for a gitlink entry, the traversal will now
continue into the tree connected to the gitlinked commit. It is the
responsibility of the callback function to somehow make the gitlinked
commit (and corresponding tree/blob) objects available, possibly by
inserting the submodule object database as an alternate odb.

Also, all existing callback function has been updated to only return
READ_TREE_RECURSIVE for directory entries, so this patch should not
introduce any changes to current behavior.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 archive.c         |    2 +-
 builtin-ls-tree.c |    9 ++-------
 merge-recursive.c |    2 +-
 tree.c            |   28 ++++++++++++++++++++++++++++
 4 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/archive.c b/archive.c
index 9ac455d..e6de039 100644
--- a/archive.c
+++ b/archive.c
@@ -132,7 +132,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
 		err = write_entry(args, sha1, path.buf, path.len, mode, NULL, 0);
 		if (err)
 			return err;
-		return READ_TREE_RECURSIVE;
+		return (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
 	}
 
 	buffer = sha1_file_to_archive(path_without_prefix, sha1, mode,
diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c
index 5b63e6e..fca4631 100644
--- a/builtin-ls-tree.c
+++ b/builtin-ls-tree.c
@@ -68,13 +68,8 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
 		 *
 		 * Something similar to this incomplete example:
 		 *
-		if (show_subprojects(base, baselen, pathname)) {
-			struct child_process ls_tree;
-
-			ls_tree.dir = base;
-			ls_tree.argv = ls-tree;
-			start_command(&ls_tree);
-		}
+		if (show_subprojects(base, baselen, pathname))
+			retval = READ_TREE_RECURSIVE;
 		 *
 		 */
 		type = commit_type;
diff --git a/merge-recursive.c b/merge-recursive.c
index b97026b..ee853b9 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -237,7 +237,7 @@ static int save_files_dirs(const unsigned char *sha1,
 		string_list_insert(newpath, &o->current_file_set);
 	free(newpath);
 
-	return READ_TREE_RECURSIVE;
+	return (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
 }
 
 static int get_files_dirs(struct merge_options *o, struct tree *tree)
diff --git a/tree.c b/tree.c
index 03e782a..dfe4d5f 100644
--- a/tree.c
+++ b/tree.c
@@ -131,6 +131,34 @@ int read_tree_recursive(struct tree *tree,
 			if (retval)
 				return -1;
 			continue;
+		} else if (S_ISGITLINK(entry.mode)) {
+			int retval;
+			struct strbuf path;
+			unsigned int entrylen;
+			struct commit *commit;
+
+			entrylen = tree_entry_len(entry.path, entry.sha1);
+			strbuf_init(&path, baselen + entrylen + 1);
+			strbuf_add(&path, base, baselen);
+			strbuf_add(&path, entry.path, entrylen);
+			strbuf_addch(&path, '/');
+
+			commit = lookup_commit(entry.sha1);
+			if (!commit)
+				die("Commit %s in submodule path %s not found",
+				    sha1_to_hex(entry.sha1), path.buf);
+
+			if (parse_commit(commit))
+				die("Invalid commit %s in submodule path %s",
+				    sha1_to_hex(entry.sha1), path.buf);
+
+			retval = read_tree_recursive(commit->tree,
+						     path.buf, path.len,
+						     stage, match, fn, context);
+			strbuf_release(&path);
+			if (retval)
+				return -1;
+			continue;
 		}
 	}
 	return 0;
-- 
1.6.1.150.g5e733b

^ permalink raw reply related

* [RFC/PATCH v3 2/3] sha1_file: prepare for adding alternates on demand
From: Lars Hjemli @ 2009-01-22 21:17 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin, René Scharfe
In-Reply-To: <1232659071-14401-2-git-send-email-hjemli@gmail.com>

The new function add_alt_odb() can be used to add alternate object
databases dynamically (i.e. after parsing of objects/info/alternates).
It will be used by git-archive to implement inclusion of submodules
by adding submodule object databases during tree traversal.

To make the function usable from call-sites which doesn't require the
add_alt_odb() to succeed, it takes a 'quiet' parameter which is passed
on to the underlying alt-odb-related functions.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 cache.h     |    1 +
 sha1_file.c |   40 +++++++++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/cache.h b/cache.h
index 8e1af26..ccfad5f 100644
--- a/cache.h
+++ b/cache.h
@@ -724,6 +724,7 @@ extern struct alternate_object_database {
 	char base[FLEX_ARRAY]; /* more */
 } *alt_odb_list;
 extern void prepare_alt_odb(void);
+extern int add_alt_odb(char *path, int quiet);
 extern void add_to_alternates_file(const char *reference);
 typedef int alt_odb_fn(struct alternate_object_database *, void *);
 extern void foreach_alt_odb(alt_odb_fn, void*);
diff --git a/sha1_file.c b/sha1_file.c
index f08493f..8b5540d 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -235,7 +235,7 @@ char *sha1_pack_index_name(const unsigned char *sha1)
 struct alternate_object_database *alt_odb_list;
 static struct alternate_object_database **alt_odb_tail;
 
-static void read_info_alternates(const char * alternates, int depth);
+static void read_info_alternates(const char * alternates, int depth, int quiet);
 
 /*
  * Prepare alternate object database registry.
@@ -252,7 +252,8 @@ static void read_info_alternates(const char * alternates, int depth);
  * SHA1, an extra slash for the first level indirection, and the
  * terminating NUL.
  */
-static int link_alt_odb_entry(const char * entry, int len, const char * relative_base, int depth)
+static int link_alt_odb_entry(const char * entry, int len,
+			      const char * relative_base, int depth, int quiet)
 {
 	const char *objdir = get_object_directory();
 	struct alternate_object_database *ent;
@@ -285,9 +286,10 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
 
 	/* Detect cases where alternate disappeared */
 	if (!is_directory(ent->base)) {
-		error("object directory %s does not exist; "
-		      "check .git/objects/info/alternates.",
-		      ent->base);
+		if (!quiet)
+			error("object directory %s does not exist; "
+			      "check .git/objects/info/alternates.",
+			      ent->base);
 		free(ent);
 		return -1;
 	}
@@ -312,7 +314,7 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
 	ent->next = NULL;
 
 	/* recursively add alternates */
-	read_info_alternates(ent->base, depth + 1);
+	read_info_alternates(ent->base, depth + 1, quiet);
 
 	ent->base[pfxlen] = '/';
 
@@ -320,7 +322,8 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
 }
 
 static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
-				 const char *relative_base, int depth)
+				 const char *relative_base, int depth,
+				 int quiet)
 {
 	const char *cp, *last;
 
@@ -343,11 +346,12 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
 			cp++;
 		if (last != cp) {
 			if (!is_absolute_path(last) && depth) {
+				if (!quiet)
 				error("%s: ignoring relative alternate object store %s",
 						relative_base, last);
 			} else {
 				link_alt_odb_entry(last, cp - last,
-						relative_base, depth);
+						relative_base, depth, quiet);
 			}
 		}
 		while (cp < ep && *cp == sep)
@@ -356,7 +360,8 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
 	}
 }
 
-static void read_info_alternates(const char * relative_base, int depth)
+static void read_info_alternates(const char * relative_base, int depth,
+				 int quiet)
 {
 	char *map;
 	size_t mapsz;
@@ -380,7 +385,8 @@ static void read_info_alternates(const char * relative_base, int depth)
 	map = xmmap(NULL, mapsz, PROT_READ, MAP_PRIVATE, fd, 0);
 	close(fd);
 
-	link_alt_odb_entries(map, map + mapsz, '\n', relative_base, depth);
+	link_alt_odb_entries(map, map + mapsz, '\n', relative_base, depth,
+			     quiet);
 
 	munmap(map, mapsz);
 }
@@ -394,7 +400,7 @@ void add_to_alternates_file(const char *reference)
 	if (commit_lock_file(lock))
 		die("could not close alternates file");
 	if (alt_odb_tail)
-		link_alt_odb_entries(alt, alt + strlen(alt), '\n', NULL, 0);
+		link_alt_odb_entries(alt, alt + strlen(alt), '\n', NULL, 0, 0);
 }
 
 void foreach_alt_odb(alt_odb_fn fn, void *cb)
@@ -418,9 +424,9 @@ void prepare_alt_odb(void)
 	if (!alt) alt = "";
 
 	alt_odb_tail = &alt_odb_list;
-	link_alt_odb_entries(alt, alt + strlen(alt), PATH_SEP, NULL, 0);
+	link_alt_odb_entries(alt, alt + strlen(alt), PATH_SEP, NULL, 0, 0);
 
-	read_info_alternates(get_object_directory(), 0);
+	read_info_alternates(get_object_directory(), 0, 0);
 }
 
 static int has_loose_object_local(const unsigned char *sha1)
@@ -2573,3 +2579,11 @@ int read_pack_header(int fd, struct pack_header *header)
 		return PH_ERROR_PROTOCOL;
 	return 0;
 }
+
+int add_alt_odb(char *path, int quiet)
+{
+	int err = link_alt_odb_entry(path, strlen(path), NULL, 0, quiet);
+	if (!err)
+		prepare_packed_git_one(path, 0);
+	return err;
+}
-- 
1.6.1.150.g5e733b

^ permalink raw reply related

* [RFC/PATCH v3 3/3] archive.c: add basic support for submodules
From: Lars Hjemli @ 2009-01-22 21:17 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin, René Scharfe
In-Reply-To: <1232659071-14401-3-git-send-email-hjemli@gmail.com>

The new --submodules option is used to trigger inclusion of checked
out submodules in the archive.

The implementation currently does not verify that the submodule has
been registered as 'interesting' in .git/config, neither does it resolve
the currently checked out submodule HEAD but instead uses the commit SHA1
recorded in the gitlink entry to identify the submodule root tree.

The plan is to fix these limitations by extending --submodules to allow
certain flags/options:
  a|c|r     include any|checked out|registered submodules
  H         resolve submodule HEAD to decide which tree to include
  g:<name>  only include submodules in group <name>

The syntax would then become '--submodules[=[a|c|r][H][g:<name>]]' and
group membership could be specified in .git/config and/or .gitmodules.
The current behavior would then match '--submodules=c' (which might be a
sensible default when only --submodules is specified).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 Documentation/git-archive.txt |    3 +
 archive.c                     |   53 ++++++++++++++++++-
 archive.h                     |    1 +
 t/t5001-archive-submodules.sh |  121 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 177 insertions(+), 1 deletions(-)
 create mode 100755 t/t5001-archive-submodules.sh

diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index 41cbf9c..ddfa343 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -51,6 +51,9 @@ OPTIONS
 	This can be any options that the archiver backend understand.
 	See next section.
 
+--submodules::
+	Include all checked out submodules in the archive.
+
 --remote=<repo>::
 	Instead of making a tar archive from local repository,
 	retrieve a tar archive from a remote repository.
diff --git a/archive.c b/archive.c
index e6de039..1709a01 100644
--- a/archive.c
+++ b/archive.c
@@ -96,6 +96,52 @@ struct archiver_context {
 	write_archive_entry_fn_t write_entry;
 };
 
+/* Given the root directory of a non-bare repository, return the path
+ * to the corresponding GITDIR, or NULL if not found. The return-value
+ * is malloc'd by this function and should be free'd by the caller.
+ */
+static char *get_gitdir(const char *root)
+{
+	const char *path, *tmp;
+	struct stat st;
+
+	if (!root)
+		return NULL;
+
+	if (root[strlen(root) - 1] == '/')
+		path = mkpath("%s.git", root);
+	else
+		path = mkpath("%s/.git", root);
+
+	tmp = read_gitfile_gently(path);
+	if (tmp)
+		path = tmp;
+
+	if (stat(path, &st) || !S_ISDIR(st.st_mode))
+		return NULL;
+	return xstrdup(path);
+}
+
+/* Return READ_TREE_RECURSIVE if we should recurse into the gitlinked
+ * repository or 0 if it should be skipped.
+ */
+static int recurse_gitlink(struct archiver_args *args, const char *path)
+{
+	char *gitdir;
+	char *objdir;
+
+	if (!args->submodules)
+		return 0;
+	gitdir = get_gitdir(path);
+	if (!gitdir)
+		return 0;
+	objdir = mkpath("%s/objects", gitdir);
+	free(gitdir);
+	if (add_alt_odb(objdir, 0))
+		return -1;
+	return READ_TREE_RECURSIVE;
+}
+
 static int write_archive_entry(const unsigned char *sha1, const char *base,
 		int baselen, const char *filename, unsigned mode, int stage,
 		void *context)
@@ -132,7 +178,8 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
 		err = write_entry(args, sha1, path.buf, path.len, mode, NULL, 0);
 		if (err)
 			return err;
-		return (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
+		return (S_ISDIR(mode) ? READ_TREE_RECURSIVE :
+					recurse_gitlink(args, path.buf));
 	}
 
 	buffer = sha1_file_to_archive(path_without_prefix, sha1, mode,
@@ -255,6 +302,7 @@ static int parse_archive_args(int argc, const char **argv,
 	const char *exec = NULL;
 	int compression_level = -1;
 	int verbose = 0;
+	int submodules = 0;
 	int i;
 	int list = 0;
 	struct option opts[] = {
@@ -262,6 +310,8 @@ static int parse_archive_args(int argc, const char **argv,
 		OPT_STRING(0, "format", &format, "fmt", "archive format"),
 		OPT_STRING(0, "prefix", &base, "prefix",
 			"prepend prefix to each pathname in the archive"),
+		OPT_BOOLEAN(0, "submodules", &submodules,
+			"include checked out submodules in the archive"),
 		OPT__VERBOSE(&verbose),
 		OPT__COMPR('0', &compression_level, "store only", 0),
 		OPT__COMPR('1', &compression_level, "compress faster", 1),
@@ -319,6 +369,7 @@ static int parse_archive_args(int argc, const char **argv,
 	args->verbose = verbose;
 	args->base = base;
 	args->baselen = strlen(base);
+	args->submodules = submodules;
 
 	return argc;
 }
diff --git a/archive.h b/archive.h
index 0b15b35..aff3fcd 100644
--- a/archive.h
+++ b/archive.h
@@ -11,6 +11,7 @@ struct archiver_args {
 	const char **pathspec;
 	unsigned int verbose : 1;
 	int compression_level;
+	int submodules;
 };
 
 typedef int (*write_archive_fn_t)(struct archiver_args *);
diff --git a/t/t5001-archive-submodules.sh b/t/t5001-archive-submodules.sh
new file mode 100755
index 0000000..6471984
--- /dev/null
+++ b/t/t5001-archive-submodules.sh
@@ -0,0 +1,121 @@
+#!/bin/sh
+
+test_description='git archive can include submodule content'
+
+. ./test-lib.sh
+
+add_file()
+{
+	git add $1 &&
+	git commit -m "added $1"
+}
+
+add_submodule()
+{
+	mkdir $1 && (
+		cd $1 &&
+		git init &&
+		echo "File $2" >$2 &&
+		add_file $2
+	) &&
+	add_file $1
+}
+
+test_expect_success 'by default, all submodules are ignored' '
+	echo "File 1" >1 &&
+	add_file 1 &&
+	add_submodule 2 3 &&
+	add_submodule 4 5 &&
+	cat <<EOF >expected &&
+1
+2/
+4/
+EOF
+	git archive HEAD >normal.tar &&
+	tar -tf normal.tar >actual &&
+	test_cmp expected actual
+'
+
+test_debug 'tar -tf normal.tar'
+
+test_expect_success 'with --submodules, checked-out submodules are included' '
+	cat <<EOF >expected &&
+1
+2/
+2/3
+4/
+4/5
+EOF
+	git archive --submodules HEAD >full.tar &&
+	tar -tf full.tar >actual &&
+	test_cmp expected actual
+'
+
+test_debug 'tar -tf full.tar'
+
+test_expect_success 'submodules in submodules are supported' '
+	(cd 4 && add_submodule 6 7) &&
+	add_file 4 &&
+	cat <<EOF >expected &&
+1
+2/
+2/3
+4/
+4/5
+4/6/
+4/6/7
+EOF
+	git archive --submodules HEAD >recursive.tar &&
+	tar -tf recursive.tar >actual &&
+	test_cmp expected actual
+'
+
+test_debug 'tar -tf recursive.tar'
+
+test_expect_success 'packed submodules are supported' '
+	cat <<EOF >expected &&
+1
+2/
+2/3
+4/
+4/5
+4/6/
+4/6/7
+EOF
+	msg=$(cd 2 && git repack -ad && git count-objects) &&
+	test "$msg" = "0 objects, 0 kilobytes" &&
+	git archive --submodules HEAD >packed.tar &&
+	tar -tf packed.tar >actual &&
+	test_cmp expected actual
+'
+
+test_debug 'tar -tf packed.tar'
+
+test_expect_success 'a missing submodule pack triggers an error' '
+	find 2/.git/objects/pack -type f | xargs rm &&
+	test_must_fail git archive --submodules HEAD
+'
+
+test_expect_success 'non-checked out submodules are ignored' '
+	cat <<EOF >expected &&
+1
+2/
+4/
+4/5
+4/6/
+4/6/7
+EOF
+	rm -rf 2/.git &&
+	git archive --submodules HEAD >partial.tar &&
+	tar -tf partial.tar >actual &&
+	test_cmp expected actual
+'
+
+test_debug 'tar -tf partial.tar'
+
+test_expect_success 'missing objects in a submodule triggers an error' '
+	find 4/.git/objects -type f | xargs rm &&
+	test_must_fail git archive --submodules HEAD
+'
+
+test_done
-- 
1.6.1.150.g5e733b

^ permalink raw reply related

* how to force a commit date matching info from a mbox ?
From: Christian MICHON @ 2009-01-22 22:41 UTC (permalink / raw)
  To: git list

Hi list,

I've a big set of patches in a mbox file: there's sufficient info
inside for git-am to work.

Yet, each time I do import these, my sha1sums are changing because of
different commit dates.

I'd like to force the commit date to match the info/date from the time
I received the email (and therefore always get back the right
sha1sums).

is this possible ?

There's hundreds of these patches: I'm looking for the right switch or
1 liner trick instead of a long shell script which will import 1 by 1
the patches and force the commit date by environment.

TIA

-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !

^ permalink raw reply

* [JGIT PATCH 00/10] Merge API v2
From: Shawn O. Pearce @ 2009-01-22 23:28 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

2nd attempt at the merge API.  Changes from my prior posting last fall:

 - Fixed the bug Robin identified (the first patch in the series)
 - Rebased against current master
 - Basic smoke tests provided by Robin

Shawn O. Pearce (10):
  Fix TreeWalk.idEqual when both trees are missing the path
  Expose the raw path for the current entry of a TreeWalk
  Expose DirCacheEntry.getFileMode as a utility function
  Add writeTree support to DirCache
  Allow a DirCache to be created with no backing store file
  Allow CanonicalTreeParsers to be created with a UTF-8 path prefix
  Recursively load an entire tree into a DirCacheBuilder
  Allow DirCacheEntry instances to be created with stage > 0
  Define a basic merge API, and a two-way tree merge strategy
  Add a few simple merge test cases

 .../spearce/jgit/test/resources/create-second-pack |   13 +-
 ...ck-3280af9c07ee18a87705ef50b0cc4cd20266cf12.idx |  Bin 0 -> 1296 bytes
 ...k-3280af9c07ee18a87705ef50b0cc4cd20266cf12.pack |  Bin 0 -> 562 bytes
 ...ck-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745.idx |  Bin 1088 -> 1100 bytes
 ...ck-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.idx |  Bin 2696 -> 2976 bytes
 ...k-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.pack |  Bin 5956 -> 5901 bytes
 .../org/spearce/jgit/test/resources/packed-refs    |    4 +-
 .../org/spearce/jgit/lib/RepositoryTestCase.java   |    3 +-
 .../org/spearce/jgit/merge/SimpleMergeTest.java    |   86 ++++++++
 .../org/spearce/jgit/transport/TransportTest.java  |    2 +-
 .../src/org/spearce/jgit/dircache/DirCache.java    |   37 ++++
 .../org/spearce/jgit/dircache/DirCacheBuilder.java |   65 ++++++
 .../org/spearce/jgit/dircache/DirCacheEntry.java   |   61 +++++-
 .../org/spearce/jgit/dircache/DirCacheTree.java    |  115 +++++++++++
 .../spearce/jgit/errors/UnmergedPathException.java |   67 ++++++
 .../src/org/spearce/jgit/lib/FileMode.java         |    7 +
 .../src/org/spearce/jgit/lib/ObjectWriter.java     |   12 +-
 .../src/org/spearce/jgit/merge/MergeStrategy.java  |  134 ++++++++++++
 .../src/org/spearce/jgit/merge/Merger.java         |  213 ++++++++++++++++++++
 .../org/spearce/jgit/merge/StrategyOneSided.java   |   98 +++++++++
 .../jgit/merge/StrategySimpleTwoWayInCore.java     |  179 ++++++++++++++++
 .../jgit/treewalk/AbstractTreeIterator.java        |   31 +++
 .../spearce/jgit/treewalk/CanonicalTreeParser.java |   30 +++
 .../src/org/spearce/jgit/treewalk/TreeWalk.java    |   28 +++-
 24 files changed, 1170 insertions(+), 15 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12.idx
 create mode 100644 org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12.pack
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/merge/SimpleMergeTest.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/errors/UnmergedPathException.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/Merger.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/StrategyOneSided.java
 create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java

^ permalink raw reply

* [JGIT PATCH 02/10] Expose the raw path for the current entry of a TreeWalk
From: Shawn O. Pearce @ 2009-01-22 23:28 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git
In-Reply-To: <1232666890-23488-2-git-send-email-spearce@spearce.org>

Copying the path byte array (keeping it encoded in UTF-8) is quicker
than converting to String and then back again to UTF-8 when creating
a DirCacheEntry for the current position in a TreeWalk.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/treewalk/TreeWalk.java    |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
index 414587c..22040e3 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
@@ -663,6 +663,21 @@ public String getPathString() {
 	}
 
 	/**
+	 * Get the current entry's complete path as a UTF-8 byte array.
+	 * 
+	 * @return complete path of the current entry, from the root of the
+	 *         repository. If the current entry is in a subtree there will be at
+	 *         least one '/' in the returned string.
+	 */
+	public byte[] getRawPath() {
+		final AbstractTreeIterator t = currentHead;
+		final int n = t.pathLen;
+		final byte[] r = new byte[n];
+		System.arraycopy(t.path, 0, r, 0, n);
+		return r;
+	}
+
+	/**
 	 * Test if the supplied path matches the current entry's path.
 	 * <p>
 	 * This method tests that the supplied path is exactly equal to the current
-- 
1.6.1.399.g0d272

^ permalink raw reply related

* [JGIT PATCH 01/10] Fix TreeWalk.idEqual when both trees are missing the path
From: Shawn O. Pearce @ 2009-01-22 23:28 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git
In-Reply-To: <1232666890-23488-1-git-send-email-spearce@spearce.org>

The Javadoc of idEqual() says its simply a faster form of
getObjectId(nthA).equals(getObjectId(nthB)), but its code
didn't match that definition when both trees didn't exist
at the current path.

If a tree doesn't exist for the current path getObjectId() returns
ObjectId.zero(), indicating the "magic" 0{40} SHA-1 for the current
path.  If both tree entries don't exist for the current path, we
should be doing a compare of ObjectId.zero() against ObjectId.zero(),
which must be true as the values are the same.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/treewalk/TreeWalk.java    |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
index ecf8851..414587c 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
@@ -616,7 +616,16 @@ public boolean idEqual(final int nthA, final int nthB) {
 		final AbstractTreeIterator ch = currentHead;
 		final AbstractTreeIterator a = trees[nthA];
 		final AbstractTreeIterator b = trees[nthB];
-		return a.matches == ch && b.matches == ch && a.idEqual(b);
+		if (a.matches == ch && b.matches == ch)
+			return a.idEqual(b);
+		if (a.matches != ch && b.matches != ch) {
+			// If neither tree matches the current path node then neither
+			// tree has this entry. In such case the ObjectId is zero(),
+			// and zero() is always equal to zero().
+			//
+			return true;
+		}
+		return false;
 	}
 
 	/**
-- 
1.6.1.399.g0d272

^ permalink raw reply related

* [JGIT PATCH 03/10] Expose DirCacheEntry.getFileMode as a utility function
From: Shawn O. Pearce @ 2009-01-22 23:28 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git
In-Reply-To: <1232666890-23488-3-git-send-email-spearce@spearce.org>

Its easier to get the FileMode object in some applications than to
get the raw mode and convert it to the FileMode in the application
code.  Its slower, but sometimes you just have to have the proper
FileMode singleton.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/dircache/DirCacheEntry.java   |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
index cc683d7..355cd3e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
@@ -295,6 +295,15 @@ public int getRawMode() {
 	}
 
 	/**
+	 * Obtain the {@link FileMode} for this entry.
+	 * 
+	 * @return the file mode singleton for this entry.
+	 */
+	public FileMode getFileMode() {
+		return FileMode.fromBits(getRawMode());
+	}
+
+	/**
 	 * Set the file mode for this entry.
 	 *
 	 * @param mode
-- 
1.6.1.399.g0d272

^ permalink raw reply related

* [JGIT PATCH 06/10] Allow CanonicalTreeParsers to be created with a UTF-8 path prefix
From: Shawn O. Pearce @ 2009-01-22 23:28 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git
In-Reply-To: <1232666890-23488-6-git-send-email-spearce@spearce.org>

Creating an iterator with a path prefix permits a tree to be
"mounted" at a different part of a repository, permitting more
sophisticated merge strategies beyond just 1:1 path matching.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../jgit/treewalk/AbstractTreeIterator.java        |   31 ++++++++++++++++++++
 .../spearce/jgit/treewalk/CanonicalTreeParser.java |   30 +++++++++++++++++++
 .../src/org/spearce/jgit/treewalk/TreeWalk.java    |    2 +-
 3 files changed, 62 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
index 791056c..62ca69c 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
@@ -172,6 +172,37 @@ protected AbstractTreeIterator(final String prefix) {
 	}
 
 	/**
+	 * Create a new iterator with no parent and a prefix.
+	 * <p>
+	 * The prefix path supplied is inserted in front of all paths generated by
+	 * this iterator. It is intended to be used when an iterator is being
+	 * created for a subsection of an overall repository and needs to be
+	 * combined with other iterators that are created to run over the entire
+	 * repository namespace.
+	 *
+	 * @param prefix
+	 *            position of this iterator in the repository tree. The value
+	 *            may be null or the empty array to indicate the prefix is the
+	 *            root of the repository. A trailing slash ('/') is
+	 *            automatically appended if the prefix does not end in '/'.
+	 */
+	protected AbstractTreeIterator(final byte[] prefix) {
+		parent = null;
+
+		if (prefix != null && prefix.length > 0) {
+			pathLen = prefix.length;
+			path = new byte[Math.max(DEFAULT_PATH_SIZE, pathLen + 1)];
+			System.arraycopy(prefix, 0, path, 0, pathLen);
+			if (path[pathLen - 1] != '/')
+				path[pathLen++] = '/';
+			pathOffset = pathLen;
+		} else {
+			path = new byte[DEFAULT_PATH_SIZE];
+			pathOffset = 0;
+		}
+	}
+	
+	/**
 	 * Create an iterator for a subtree of an existing iterator.
 	 * 
 	 * @param p
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
index 2bcf792..ed883bd 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
@@ -67,6 +67,36 @@ public CanonicalTreeParser() {
 		raw = EMPTY;
 	}
 
+	/**
+	 * Create a new parser for a tree appearing in a subset of a repository.
+	 * 
+	 * @param prefix
+	 *            position of this iterator in the repository tree. The value
+	 *            may be null or the empty array to indicate the prefix is the
+	 *            root of the repository. A trailing slash ('/') is
+	 *            automatically appended if the prefix does not end in '/'.
+	 * @param repo
+	 *            repository to load the tree data from.
+	 * @param treeId
+	 *            identity of the tree being parsed; used only in exception
+	 *            messages if data corruption is found.
+	 * @param curs
+	 *            a window cursor to use during data access from the repository.
+	 * @throws MissingObjectException
+	 *             the object supplied is not available from the repository.
+	 * @throws IncorrectObjectTypeException
+	 *             the object supplied as an argument is not actually a tree and
+	 *             cannot be parsed as though it were a tree.
+	 * @throws IOException
+	 *             a loose object or pack file could not be read.
+	 */
+	public CanonicalTreeParser(final byte[] prefix, final Repository repo,
+			final ObjectId treeId, final WindowCursor curs)
+			throws IncorrectObjectTypeException, IOException {
+		super(prefix);
+		reset(repo, treeId, curs);
+	}
+
 	private CanonicalTreeParser(final CanonicalTreeParser p) {
 		super(p);
 	}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
index 22040e3..416e027 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
@@ -354,7 +354,7 @@ public void reset(final AnyObjectId[] ids) throws MissingObjectException,
 				o = trees[i];
 				while (o.parent != null)
 					o = o.parent;
-				if (o instanceof CanonicalTreeParser) {
+				if (o instanceof CanonicalTreeParser && o.pathOffset == 0) {
 					o.matches = null;
 					o.matchShift = 0;
 					((CanonicalTreeParser) o).reset(db, ids[i], curs);
-- 
1.6.1.399.g0d272

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox