* Submodule idea
From: Daniel Barkalow @ 2007-09-29 19:04 UTC (permalink / raw)
To: git
I *think* that it would be a great benefit if "git submodule update" would
leave you on a branch if (a) you were on that branch before, and (b)
pulling on that branch would update it to the commit that the superproject
specifies for that submodule.
Or maybe there should be a "git submodule fetch" which fetches from the
remote, and replaces FETCH_HEAD with the superproject's index entry, and
"git submodule pull" would merge it? (With the model being that the entry
in the superproject is an additional remote that you both track and
publish to)
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Re: Submodule usability
From: Daniel Barkalow @ 2007-09-29 19:02 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: git
In-Reply-To: <20070929185238.GB19943@uranus.ravnborg.org>
On Sat, 29 Sep 2007, Sam Ravnborg wrote:
> Hi Daniel
> On Sat, Sep 29, 2007 at 01:24:53PM -0400, Daniel Barkalow wrote:
> >
> > Also, would it be reasonable to have a gitmodules option for submodules
> > that the supermodule doesn't make sense without? E.g., multiple projects
> > are now using kbuild as their build system,
>
> Out of couriosity...
> I know of busybox and klibc.
> Are there any others using kbuild these days?
>
> I see that several build system share some ideas with kbuild
> which I btw am glad to see.
> But if there are enough project taking benefit of kbuild I should
> maybe revisit my idea to factor out all the common stuff somehow.
I'm only sure of busybox and klibc (3 including the kernel is "multiple"),
but IIRC a number of linux-specific userspace projects seem awfully
similar. I wouldn't be surprised if the build systems that currently share
only ideas would share code if it were factored out.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Stashing untracked files
From: Neil Macneale @ 2007-09-29 18:27 UTC (permalink / raw)
To: git
Hi All,
I'm new to git, and I have a question regarding the best way to do
something.
When using "git stash," in some cases I'd like to stash away files that
are currently untracked. It seems to me like there should be a way to
stash everything in a working directory so that the end result is a
pristine tree. Then applying the stash will reinstate those file as
untracked.
I understand that is not always desired, but sometimes it is (for me
anyway). Perhaps an option like "git stash -u" could provide this behavior?
Is there some other approach that makes more sense? I don't want to
start looking into this until I have some idea if this is a sane idea :-)
Thanks,
Neil
^ permalink raw reply
* Re: Submodule usability
From: Sam Ravnborg @ 2007-09-29 18:52 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0709291302240.5926@iabervon.org>
Hi Daniel
On Sat, Sep 29, 2007 at 01:24:53PM -0400, Daniel Barkalow wrote:
>
> Also, would it be reasonable to have a gitmodules option for submodules
> that the supermodule doesn't make sense without? E.g., multiple projects
> are now using kbuild as their build system,
Out of couriosity...
I know of busybox and klibc.
Are there any others using kbuild these days?
I see that several build system share some ideas with kbuild
which I btw am glad to see.
But if there are enough project taking benefit of kbuild I should
maybe revisit my idea to factor out all the common stuff somehow.
Sam
^ permalink raw reply
* Re: [PATCH 2/2] Replace literal STRLEN_ #defines in refs.h with compiler evaluated expressions
From: Linus Torvalds @ 2007-09-29 18:15 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Andy Parkins, git
In-Reply-To: <7vd4w1l872.fsf@gitster.siamese.dyndns.org>
On Sat, 29 Sep 2007, Junio C Hamano wrote:
>
> I do not think the above is wrong per se, but doesn't a good
> compiler optimize
>
> #define PATH_REMOTES "remotes/"
> #define STRLEN_PATH_REMOTES strlen(PATH_REMOTES)
Gcc does, yes.
HOWEVER.
Using "strlen()" may be optimized at compile-time, but it still ends up
resulting in illegal C code if the constant needs to be a constant in the
semantic sense.
IOW, the "sizeof()" trick can be portably used for things like array
declarations etc. But strlen() cannot. Ie
char array[sizeof("hello")-1];
is legal in non-function scope, but doing the same with "strlen()" is not.
(That said, gcc has been known to accept bad C code, and will in fact
accept this one too!)
Linus
^ permalink raw reply
* BUG: git remote show origin => error code 1
From: Jari Aalto @ 2007-09-29 18:13 UTC (permalink / raw)
To: git
Consider this:
$ git remote show origin
No such remote origin
$ echo $?
0
Perhaps the code should return non-zero in this case, so that shell
scripts could use construct:
git remote show origin; || <another action>
Jari
--
Welcome to FOSS revolution: we fix and modify until it shines
^ permalink raw reply
* Submodule usability
From: Daniel Barkalow @ 2007-09-29 17:24 UTC (permalink / raw)
To: git
Would it be feasible in general to have "git status" cascade into
submodules if they're checked out? As it is now, in a project with
submodules, a "git commit -a" at the top can create a commit that lacks
changes that are in the working tree and aren't mentioned to the user at
all, which is a sure recipe for a stream of "add the change I forgot to
add last time" follow-up commits.
While I'm on that topic, I think I want an "includesfile" config option
that specifies patterns that should never be present untracked (but only
as per-user configuration, since I think that's exclusively a matter of
personal taste). I'll probably code this up myself unless I've missed
somebody else doing it already. My first guess at effect is -a adds them,
and they appear as "not added" in the "modified" section of status output
instead of the "untracked" section.
Also, would it be reasonable to have a gitmodules option for submodules
that the supermodule doesn't make sense without? E.g., multiple projects
are now using kbuild as their build system, so, in order to share
improvements to kbuild between projects, it would be useful to have it as
a submodule. But, by default, the kernel wouldn't come with its build
system any more, which would be a pain. So have a tracked option for the
submodule that says that, when checking out the superproject, this
particular subproject should be updated automatically.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Re: [PATCH 1/1] --color and --no-color git-log options don't need diffs to be computed.
From: Junio C Hamano @ 2007-09-29 17:02 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: git
In-Reply-To: <20070929123724.01BB045EC@madism.org>
Pierre Habouzit <madcoder@debian.org> writes:
> Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> ---
>
> revision.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/revision.c b/revision.c
> index 33d092c..0dee835 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -1209,8 +1209,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
>
> opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
> if (opts > 0) {
> - if (strcmp(argv[i], "-z"))
> - revs->diff = 1;
> + revs->diff = strcmp(argv[i], "-z")
> + && strcmp(argv[i], "--color")
> + && strcmp(argv[i], "--no-color");
> i += opts - 1;
> continue;
> }
Aside from the "don't override the option that is already set"
comment from David, I am somewhat unhappy that this piece
already knows too much about which option to diff potentially
changes the output (but not commits us to produce the diff) and
which option causes us to actually produce output.
^ permalink raw reply
* Re: [PATCH 2/2] Replace literal STRLEN_ #defines in refs.h with compiler evaluated expressions
From: Junio C Hamano @ 2007-09-29 16:58 UTC (permalink / raw)
To: Andy Parkins; +Cc: git
In-Reply-To: <200709291400.13880.andyparkins@gmail.com>
Andy Parkins <andyparkins@gmail.com> writes:
> Bill Lear pointed out that the following:
>
> #define PATH_REMOTES "remotes/"
> #define STRLEN_PATH_REMOTES 8
>
> Could be replaced by the less error-prone
>
> #define PATH_REMOTES "remotes/"
> #define LIT_STRLEN(S) ((sizeof(S) / sizeof(S[0])) -1)
> #define STRLEN_PATH_REMOTES LIT_STRLEN(PATH_REMOTES)
>
> which is what this patch does.
I do not think the above is wrong per se, but doesn't a good
compiler optimize
#define PATH_REMOTES "remotes/"
#define STRLEN_PATH_REMOTES strlen(PATH_REMOTES)
... and much later in some *.c file that includes the
... above and <string.h>
foo = strlen(PATH_REMOTES)
anyway?
^ permalink raw reply
* Fix revision log diff setup, avoid unnecessary diff generation
From: Linus Torvalds @ 2007-09-29 16:50 UTC (permalink / raw)
To: Junio C Hamano, Pierre Habouzit; +Cc: Git Mailing List
In-Reply-To: <20070929123724.01BB045EC@madism.org>
We used to incorrectly start calculating diffs whenever any argument but
'-z' was recognized by the diff options parsing. That was bogus, since not
all arguments result in diffs being needed, so we just waste a lot of time
and effort on calculating diffs that don't matter.
This actually also fixes another bug in "git log". Try this:
git log -C
and notice how it prints an extra empty line in between log entries, even
though it never prints the actual diff (because we didn't ask for any diff
format, so the diff machinery never prints anything).
With this patch, that bogus empty line is gone, because "revs->diff" is
never set. So this isn't just a "wasted time and effort" issue, it's also
a slight semantic fix.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
On Sat, 29 Sep 2007, Pierre Habouzit wrote:
>
> - if (strcmp(argv[i], "-z"))
> - revs->diff = 1;
> + revs->diff = strcmp(argv[i], "-z")
> + && strcmp(argv[i], "--color")
> + && strcmp(argv[i], "--no-color");
The old code was already pretty damn ugly, the new code is worse (never
mind the bug).
I don't think we should care *at*all* about the actual argument string, we
should just look at what the diffopts end up being at the end.
So I would suggest a patch like the appended instead!
(Maybe there are other cases where we'd want to run the diff, but I can't
think of any)
Linus
---
revision.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index 33d092c..6584713 100644
--- a/revision.c
+++ b/revision.c
@@ -1209,8 +1209,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
if (opts > 0) {
- if (strcmp(argv[i], "-z"))
- revs->diff = 1;
i += opts - 1;
continue;
}
@@ -1254,6 +1252,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
add_pending_object_with_mode(revs, object, def, mode);
}
+ /* Did the user ask for any diff output? Run the diff! */
+ if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT)
+ revs->diff = 1;
+
+ /* Pickaxe needs diffs */
+ if (revs->diffopt.pickaxe)
+ revs->diff = 1;
+
if (revs->topo_order)
revs->limited = 1;
^ permalink raw reply related
* Re: [PATCH] rebase -i: support single-letter abbreviations for the actions
From: Avi Kivity @ 2007-09-29 16:27 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: gitster, git
In-Reply-To: <Pine.LNX.4.64.0709290231300.28395@racer.site>
Johannes Schindelin wrote:
> When you do many rebases, you can get annoyed by having to type out
> the actions "edit" or "squash" in total.
>
> This commit helps that, by allowing you to enter "e" instead of "edit",
> or "s" instead of "squash", and it also plays nice with "merge" or "amend"
> as synonyms to "squash".
>
>
Can we make "amend" like squash, except that it keeps the first commit's
authorship instead of the second? I often merge a commit with some
minor fix that comes later, and usually want to keep the original author
record.
--
Any sufficiently difficult bug is indistinguishable from a feature.
^ permalink raw reply
* Re: [PATCH 1/4] Rework progress module so that it uses less screen lines, with progress bars.
From: Pierre Habouzit @ 2007-09-29 16:07 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: git, Junio C Hamano
In-Reply-To: <alpine.LFD.0.9999.0709291030010.17881@xanadu.home>
[-- Attachment #1: Type: text/plain, Size: 670 bytes --]
On Sat, Sep 29, 2007 at 02:33:44PM +0000, Nicolas Pitre wrote:
> On Sat, 29 Sep 2007, Pierre Habouzit wrote:
>
> > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
>
> NAK.
>
> I don't mind the progress bar, but please don't supress the printing of
> the number of objects. This is the only indication we have to
> guesstimate the time needed for given operation.
As said, I don't intend this series to be integrated as is, it's just
a basis for some discussion :)
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* [PATCH] WinGit: include html pages from official git.git's html branch
From: Steffen Prohaska @ 2007-09-29 16:05 UTC (permalink / raw)
To: git; +Cc: Steffen Prohaska
In-Reply-To: <11910819531200-git-send-email-prohaska@zib.de>
It is assumed that a matching version of the html documentation
is available as the HEAD of /doc/git/html/.git. If not an error
will be reported.
This patch doesn't include a mechanism to fetch the html pages
to /doc/git/html/.git. You should manually clone them. Maybe
this could handled as a submodule of msysgit?
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
share/WinGit/release.sh | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/share/WinGit/release.sh b/share/WinGit/release.sh
index 5ab876a..8a3c197 100644
--- a/share/WinGit/release.sh
+++ b/share/WinGit/release.sh
@@ -5,6 +5,8 @@ test -z "$1" && {
exit 1
}
+test -d /doc/git/html/.git || { echo "Error: html pages in /doc/git/html/.git missing"; exit 1; }
+
TARGET="$HOME"/WinGit-$1.exe
OPTS7="-m0=lzma -mx=9 -md=64M"
TARGET7=tmp.7z
@@ -21,6 +23,9 @@ mkdir "$TMPDIR" &&
cp uninstaller.exe "$TMPDIR"/bin) &&
cd "$TMPDIR" &&
echo "Copying files" &&
+(git --git-dir=/doc/git/html/.git log --pretty=format:%s -1 HEAD &&
+ mkdir -p doc/git/html && cd doc/git/html &&
+ git --git-dir=/doc/git/html/.git archive HEAD | tar xf -) &&
(cd / && tar cf - bin/{git*,awk,basename.exe,bash.exe,bunzip2,bzip2.exe,\
cat.exe,chmod.exe,clear,cmp.exe,cp.exe,cpio,cut.exe,cvs.exe,date.exe,diff.exe,\
du.exe,echo,egrep,env.exe,expr.exe,false.exe,find.exe,gawk.exe,grep.exe,\
--
1.5.3.mingw.1.3.g195850
^ permalink raw reply related
* [PATCH] WinGit: included /bin/start in the installer
From: Steffen Prohaska @ 2007-09-29 16:05 UTC (permalink / raw)
To: git; +Cc: Steffen Prohaska
In-Reply-To: <A835C8E8-8EC5-43B7-9252-8709214DE7AD@zib.de>
/bin/start is needed to tell Windows to open html pages.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
share/WinGit/release.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/share/WinGit/release.sh b/share/WinGit/release.sh
index 67d0725..5ab876a 100644
--- a/share/WinGit/release.sh
+++ b/share/WinGit/release.sh
@@ -29,7 +29,7 @@ ls.exe,md5sum.exe,mkdir.exe,msys-1.0.dll,msysltdl-3.dll,mv.exe,patch.exe,\
patch.exe.manifest,perl.exe,printf,ps.exe,pwd,rm.exe,rmdir.exe,rxvt.exe,\
scp.exe,sed.exe,sh.exe,sleep.exe,sort.exe,split.exe,ssh-agent.exe,ssh.exe,\
tail.exe,tar.exe,tee.exe,touch.exe,tr.exe,true.exe,uname.exe,uniq.exe,vi,\
-vim.exe,wc.exe,which,xargs.exe,ssh-add.exe} lib/perl5/ share/git* share/vim) |
+vim.exe,wc.exe,which,xargs.exe,ssh-add.exe,start} lib/perl5/ share/git* share/vim) |
tar xvf - &&
mkdir lib/perl5/site_perl &&
cp /lib/{Error.pm,Git.pm} lib/perl5/site_perl/ &&
--
1.5.3.mingw.1.3.g195850
^ permalink raw reply related
* Re: A tour of git: the basics (and notes on some unfriendly messages)
From: Steffen Prohaska @ 2007-09-29 16:06 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Shawn O. Pearce, Carl Worth, git
In-Reply-To: <Pine.LNX.4.64.0709291606010.28395@racer.site>
On Sep 29, 2007, at 5:06 PM, Johannes Schindelin wrote:
> Hi,
>
> On Sat, 29 Sep 2007, Steffen Prohaska wrote:
>
>> On Sep 29, 2007, at 2:49 AM, Johannes Schindelin wrote:
>>
>>>
>>> On Fri, 28 Sep 2007, Shawn O. Pearce wrote:
>>>
>>>> On Cygwin we have man, so `git help init` (or `git init --help`)
>>>> work just fine to display the manual entry. No idea about the MSYS
>>>> port.
>>>
>>> We open the html pages. That is, we don't yet, since we do not
>>> generate the html pages just yet; asciidoc is a Python program, and
>>> Python is not available as an MSys program as far as I know (and
>>> asciidoc insists on finding files in a Unix-like file structure,
>>> so we
>>> _do_ need an MSys Python).
>>
>> I propose to clone the html pages from git.git's html branch and
>> include
>> them in the installer. I continue to believe that this is the
>> simplest
>> and fastest solution for providing html pages.
>
> I'm hesitant... The html branch is synced with the master branch.
> And we
> deviate from the master branch quite a lot ATM.
We could choose a specific commit from the html branch for the WinGit
release. I don't think we'll need modifications to the documentation
in msysgit. Selecting an older version that matches the state of msysgit
should be sufficient.
Fixes to the documentation could be committed directly to git.git.
>> I'll provide a patch (hopefully next week).
>
> This will be a good temporary workaround.
The patch following soon will assume that html is available. Maybe
we could add it as a submodule of msysgit?
I haven't looked into the submodule mechanisms and therefore will
not include it in the patch. I just manually cloned the html branch.
For now, this may be sufficient to create a WinGit installer.
Steffen
^ permalink raw reply
* Re: A tour of git: the basics (and notes on some unfriendly messages)
From: Johannes Schindelin @ 2007-09-29 15:06 UTC (permalink / raw)
To: Steffen Prohaska; +Cc: Shawn O. Pearce, Carl Worth, git
In-Reply-To: <4D958F04-D531-416A-9FB4-E4119BEC6905@zib.de>
Hi,
On Sat, 29 Sep 2007, Steffen Prohaska wrote:
> On Sep 29, 2007, at 2:49 AM, Johannes Schindelin wrote:
>
> >
> > On Fri, 28 Sep 2007, Shawn O. Pearce wrote:
> >
> > > On Cygwin we have man, so `git help init` (or `git init --help`)
> > > work just fine to display the manual entry. No idea about the MSYS
> > > port.
> >
> > We open the html pages. That is, we don't yet, since we do not
> > generate the html pages just yet; asciidoc is a Python program, and
> > Python is not available as an MSys program as far as I know (and
> > asciidoc insists on finding files in a Unix-like file structure, so we
> > _do_ need an MSys Python).
>
> I propose to clone the html pages from git.git's html branch and include
> them in the installer. I continue to believe that this is the simplest
> and fastest solution for providing html pages.
I'm hesitant... The html branch is synced with the master branch. And we
deviate from the master branch quite a lot ATM.
> I'll provide a patch (hopefully next week).
This will be a good temporary workaround.
Ciao,
Dscho
^ permalink raw reply
* Please pull mergetool.git
From: Theodore Ts'o @ 2007-09-29 14:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
Hi Junio,
Please pull from the "mergetool" branch at:
git://repo.or.cz/git/mergetool.git mergetool
It contains the bug fixes for git mergetool discussed recently, and is
against the maint branch. Thanks!
- Ted
Junio C Hamano (1):
Mergetool generating blank files (1.5.3)
Theodore Ts'o (2):
mergetool: fix emerge when running in a subdirectory
mergetool: Fix typo in options passed to kdiff3
^ permalink raw reply
* Re: [PATCH 1/4] Rework progress module so that it uses less screen lines, with progress bars.
From: Nicolas Pitre @ 2007-09-29 14:33 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: git, Junio C Hamano
In-Reply-To: <1191062758-30631-2-git-send-email-madcoder@debian.org>
On Sat, 29 Sep 2007, Pierre Habouzit wrote:
> Signed-off-by: Pierre Habouzit <madcoder@debian.org>
NAK.
I don't mind the progress bar, but please don't supress the printing of
the number of objects. This is the only indication we have to
guesstimate the time needed for given operation.
Nicolas
^ permalink raw reply
* Re: [PATCH 1/1] --color and --no-color git-log options don't need diffs to be computed.
From: Marco Costalba @ 2007-09-29 13:07 UTC (permalink / raw)
To: Pierre Habouzit, David Kastrup, Junio C Hamano, git
In-Reply-To: <e5bfff550709290606k71cc3c50h5ea42441223dede@mail.gmail.com>
On 9/29/07, Marco Costalba <mcostalba@gmail.com> wrote:
>
> Perhaps also with an 'if' before to avoid clearing an already set
> revs->diff if the passed option does not match any of the three.
>
Please discard, I mistakenly pressed 'send' button.
^ permalink raw reply
* Re: [PATCH 1/1] --color and --no-color git-log options don't need diffs to be computed.
From: Marco Costalba @ 2007-09-29 13:06 UTC (permalink / raw)
To: Pierre Habouzit, David Kastrup, Junio C Hamano, git
In-Reply-To: <20070929125633.GC32142@artemis.corp>
On 9/29/07, Pierre Habouzit <madcoder@debian.org> wrote:
> >
> > > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> >
> > > - if (strcmp(argv[i], "-z"))
> > > - revs->diff = 1;
> > > + revs->diff = strcmp(argv[i], "-z")
> > > + && strcmp(argv[i], "--color")
> > > + && strcmp(argv[i], "--no-color");
> > > i += opts - 1;
> > > continue;
> >
> > This can clear a previously set value of revs->diff.
>
> Good catch, that should be |= of course.
>
Perhaps also with an 'if' before to avoid clearing an already set
revs->diff if the passed option does not match any of the three.
Marco
^ permalink raw reply
* [PATCH 2/2] Replace literal STRLEN_ #defines in refs.h with compiler evaluated expressions
From: Andy Parkins @ 2007-09-29 13:00 UTC (permalink / raw)
To: git
Bill Lear pointed out that the following:
#define PATH_REMOTES "remotes/"
#define STRLEN_PATH_REMOTES 8
Could be replaced by the less error-prone
#define PATH_REMOTES "remotes/"
#define LIT_STRLEN(S) ((sizeof(S) / sizeof(S[0])) -1)
#define STRLEN_PATH_REMOTES LIT_STRLEN(PATH_REMOTES)
which is what this patch does.
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
refs.h | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/refs.h b/refs.h
index 1025d04..fb58889 100644
--- a/refs.h
+++ b/refs.h
@@ -13,16 +13,17 @@ struct ref_lock {
#define REF_ISSYMREF 01
#define REF_ISPACKED 02
+#define LIT_STRLEN(S) ((sizeof(S) / sizeof(S[0])) -1)
#define PATH_OBJECTS "objects/"
-#define STRLEN_PATH_OBJECTS 8
+#define STRLEN_PATH_OBJECTS LIT_STRLEN(PATH_OBJECTS)
#define PATH_REFS "refs/"
-#define STRLEN_PATH_REFS 5
+#define STRLEN_PATH_REFS LIT_STRLEN(PATH_REFS)
#define PATH_HEADS "heads/"
-#define STRLEN_PATH_HEADS 6
+#define STRLEN_PATH_HEADS LIT_STRLEN(PATH_HEADS)
#define PATH_TAGS "tags/"
-#define STRLEN_PATH_TAGS 5
+#define STRLEN_PATH_TAGS LIT_STRLEN(PATH_TAGS)
#define PATH_REMOTES "remotes/"
-#define STRLEN_PATH_REMOTES 8
+#define STRLEN_PATH_REMOTES LIT_STRLEN(PATH_REMOTES)
#define PATH_REFS_HEADS PATH_REFS PATH_HEADS
#define STRLEN_PATH_REFS_HEADS (STRLEN_PATH_REFS+STRLEN_PATH_HEADS)
#define PATH_REFS_TAGS PATH_REFS PATH_TAGS
--
1.5.3.rc5.11.g312e
^ permalink raw reply related
* [PATCH 1/2] Change "refs/" references to symbolic constants
From: Andy Parkins @ 2007-09-29 12:59 UTC (permalink / raw)
To: git
Changed repeated use of the same constants for the ref paths to be
symbolic constants. I've defined them in refs.h
refs/ is now PATH_REFS
refs/heads/ is now PATH_REFS_HEADS
refs/tags/ is now PATH_REFS_TAGS
refs/remotes/ is now PATH_REFS_REMOTES
I've changed all references to them and made constants for the string
lengths as well. This has clarified the code in some places; for
example:
- len = strlen(refs[i]) + 11;
+ len = strlen(refs[i]) + STRLEN_PATH_REFS_TAGS + 1;
In this case 11 isn't STRLEN_PATH_REFS_HEADS, as it is in most other
cases, it's TAGS + 1. With the change to symbolic constants it's much
clearer what is happening.
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
The primary purpose of this patch is to clarify the string math that's
done whenever "refs/" paths are used. As with the HASH_WIDTH patch I
sent, when we're dealing with lines like:
url = xmalloc(strlen(repo->base) + 64);
It's much easier to tell where that 64 came from when it says:
url = xmalloc(strlen(repo->base) + STRLEN_PATH_OBJECTS + HASH_WIDTH_ASCII
+ 16);
There is more to be done really because that 16 is really
STRLEN_PATH_PACK + STRLEN_PACK_PREFIX + STRLEN_PACK_INDEX_EXTENSION
but I think that would perhaps be a bridge too far.
builtin-branch.c | 28 ++++++++++++++--------------
builtin-describe.c | 2 +-
builtin-fetch--tool.c | 10 +++++-----
builtin-fmt-merge-msg.c | 5 +++--
builtin-fsck.c | 4 ++--
builtin-init-db.c | 15 ++++++++-------
builtin-name-rev.c | 14 +++++++-------
builtin-pack-refs.c | 2 +-
builtin-push.c | 6 +++---
builtin-show-branch.c | 34 +++++++++++++++++-----------------
builtin-show-ref.c | 6 +++---
builtin-tag.c | 4 ++--
connect.c | 10 +++++-----
fetch-pack.c | 6 +++---
http-fetch.c | 31 ++++++++++++++++---------------
http-push.c | 42 +++++++++++++++++++++---------------------
local-fetch.c | 13 +++++++------
path.c | 5 +++--
receive-pack.c | 4 ++--
reflog-walk.c | 6 +++---
refs.c | 18 +++++++++---------
refs.h | 17 +++++++++++++++++
remote.c | 14 +++++++-------
setup.c | 5 +++--
sha1_name.c | 10 +++++-----
wt-status.c | 5 +++--
26 files changed, 170 insertions(+), 146 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index 5f5c182..b203b2a 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -92,12 +92,12 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
switch (kinds) {
case REF_REMOTE_BRANCH:
- fmt = "refs/remotes/%s";
+ fmt = PATH_REFS_REMOTES "%s";
remote = "remote ";
force = 1;
break;
case REF_LOCAL_BRANCH:
- fmt = "refs/heads/%s";
+ fmt = PATH_REFS_HEADS "%s";
remote = "";
break;
default:
@@ -189,15 +189,15 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
int len;
/* Detect kind */
- if (!prefixcmp(refname, "refs/heads/")) {
+ if (!prefixcmp(refname, PATH_REFS_HEADS)) {
kind = REF_LOCAL_BRANCH;
- refname += 11;
- } else if (!prefixcmp(refname, "refs/remotes/")) {
+ refname += STRLEN_PATH_REFS_HEADS;
+ } else if (!prefixcmp(refname, PATH_REFS_REMOTES)) {
kind = REF_REMOTE_BRANCH;
- refname += 13;
- } else if (!prefixcmp(refname, "refs/tags/")) {
+ refname += STRLEN_PATH_REFS_REMOTES;
+ } else if (!prefixcmp(refname, PATH_REFS_TAGS)) {
kind = REF_TAG;
- refname += 10;
+ refname += STRLEN_PATH_REFS_TAGS;
}
/* Don't add types the caller doesn't want */
@@ -400,7 +400,7 @@ static void create_branch(const char *name, const char *start_name,
char *real_ref, ref[PATH_MAX], msg[PATH_MAX + 20];
int forcing = 0;
- snprintf(ref, sizeof ref, "refs/heads/%s", name);
+ snprintf(ref, sizeof ref, PATH_REFS_HEADS "%s", name);
if (check_ref_format(ref))
die("'%s' is not a valid branch name.", name);
@@ -469,13 +469,13 @@ static void rename_branch(const char *oldname, const char *newname, int force)
if (!oldname)
die("cannot rename the current branch while not on any.");
- if (snprintf(oldref, sizeof(oldref), "refs/heads/%s", oldname) > sizeof(oldref))
+ if (snprintf(oldref, sizeof(oldref), PATH_REFS_HEADS "%s", oldname) > sizeof(oldref))
die("Old branchname too long");
if (check_ref_format(oldref))
die("Invalid branch name: %s", oldref);
- if (snprintf(newref, sizeof(newref), "refs/heads/%s", newname) > sizeof(newref))
+ if (snprintf(newref, sizeof(newref), PATH_REFS_HEADS "%s", newname) > sizeof(newref))
die("New branchname too long");
if (check_ref_format(newref))
@@ -602,9 +602,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
detached = 1;
}
else {
- if (prefixcmp(head, "refs/heads/"))
- die("HEAD not found below refs/heads!");
- head += 11;
+ if (prefixcmp(head, PATH_REFS_HEADS))
+ die("HEAD not found below " PATH_REFS_HEADS "!");
+ head += STRLEN_PATH_REFS_HEADS;
}
if (delete)
diff --git a/builtin-describe.c b/builtin-describe.c
index 669110c..09ed8f8 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -53,7 +53,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
* If --tags, then any tags are used.
* Otherwise only annotated tags are used.
*/
- if (!prefixcmp(path, "refs/tags/")) {
+ if (!prefixcmp(path, PATH_TAGS)) {
if (object->type == OBJ_TAG)
prio = 2;
else
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index 24c7e6f..521b5fc 100644
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
@@ -76,7 +76,7 @@ static int update_local_ref(const char *name,
char *msg;
just_store:
/* new ref */
- if (!strncmp(name, "refs/tags/", 10))
+ if (!prefixcmp(name, PATH_REFS_TAGS))
msg = "storing tag";
else
msg = "storing head";
@@ -94,7 +94,7 @@ static int update_local_ref(const char *name,
return 0;
}
- if (!strncmp(name, "refs/tags/", 10)) {
+ if (!prefixcmp(name, PATH_REFS_TAGS)) {
fprintf(stderr, "* %s: updating with %s\n", name, note);
show_new(type, sha1_new);
return update_ref_env("updating tag", name, sha1_new, NULL);
@@ -151,15 +151,15 @@ static int append_fetch_head(FILE *fp,
kind = "";
what = "";
}
- else if (!strncmp(remote_name, "refs/heads/", 11)) {
+ else if (!prefixcmp(remote_name, PATH_REFS_HEADS)) {
kind = "branch";
what = remote_name + 11;
}
- else if (!strncmp(remote_name, "refs/tags/", 10)) {
+ else if (!prefixcmp(remote_name, PATH_REFS_TAGS)) {
kind = "tag";
what = remote_name + 10;
}
- else if (!strncmp(remote_name, "refs/remotes/", 13)) {
+ else if (!prefixcmp(remote_name, PATH_REFS_REMOTES)) {
kind = "remote branch";
what = remote_name + 13;
}
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index ae60fcc..8700343 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -4,6 +4,7 @@
#include "diff.h"
#include "revision.h"
#include "tag.h"
+#include "refs.h"
static const char *fmt_merge_msg_usage =
"git-fmt-merge-msg [--summary] [--no-summary] [--file <file>]";
@@ -282,8 +283,8 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
if (!current_branch)
die("No current branch");
- if (!prefixcmp(current_branch, "refs/heads/"))
- current_branch += 11;
+ if (!prefixcmp(current_branch, PATH_REFS_HEADS))
+ current_branch += STRLEN_PATH_REFS_HEADS;
while (fgets(line, sizeof(line), in)) {
i++;
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 8d12287..83a2d0c 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -629,14 +629,14 @@ static int fsck_head_link(void)
if (!strcmp(head_points_at, "HEAD"))
/* detached HEAD */
null_is_error = 1;
- else if (prefixcmp(head_points_at, "refs/heads/"))
+ else if (prefixcmp(head_points_at, PATH_REFS_HEADS))
return error("HEAD points to something strange (%s)",
head_points_at);
if (is_null_sha1(sha1)) {
if (null_is_error)
return error("HEAD: detached HEAD points at nothing");
fprintf(stderr, "notice: HEAD points to an unborn branch (%s)\n",
- head_points_at + 11);
+ head_points_at + STRLEN_PATH_REFS_HEADS);
}
return 0;
}
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 763fa55..1f3c0dd 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -5,6 +5,7 @@
*/
#include "cache.h"
#include "builtin.h"
+#include "refs.h"
#ifndef DEFAULT_GIT_TEMPLATE_DIR
#define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
@@ -194,11 +195,11 @@ static int create_default_files(const char *git_dir, const char *template_path)
/*
* Create .git/refs/{heads,tags}
*/
- strcpy(path + len, "refs");
+ strcpy(path + len, PATH_REFS);
safe_create_dir(path, 1);
- strcpy(path + len, "refs/heads");
+ strcpy(path + len, PATH_REFS_HEADS);
safe_create_dir(path, 1);
- strcpy(path + len, "refs/tags");
+ strcpy(path + len, PATH_REFS_TAGS);
safe_create_dir(path, 1);
/* First copy the templates -- we might have the default
@@ -217,11 +218,11 @@ static int create_default_files(const char *git_dir, const char *template_path)
if (shared_repository) {
path[len] = 0;
adjust_shared_perm(path);
- strcpy(path + len, "refs");
+ strcpy(path + len, PATH_REFS);
adjust_shared_perm(path);
- strcpy(path + len, "refs/heads");
+ strcpy(path + len, PATH_REFS_HEADS);
adjust_shared_perm(path);
- strcpy(path + len, "refs/tags");
+ strcpy(path + len, PATH_REFS_TAGS);
adjust_shared_perm(path);
}
@@ -232,7 +233,7 @@ static int create_default_files(const char *git_dir, const char *template_path)
strcpy(path + len, "HEAD");
reinit = !read_ref("HEAD", sha1);
if (!reinit) {
- if (create_symref("HEAD", "refs/heads/master", NULL) < 0)
+ if (create_symref("HEAD", PATH_REFS_HEADS "master", NULL) < 0)
exit(1);
}
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index 03083e9..56c13d0 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -96,7 +96,7 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
struct name_ref_data *data = cb_data;
int deref = 0;
- if (data->tags_only && prefixcmp(path, "refs/tags/"))
+ if (data->tags_only && prefixcmp(path, PATH_REFS_TAGS))
return 0;
if (data->ref_filter && fnmatch(data->ref_filter, path, 0))
@@ -112,14 +112,14 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
if (o && o->type == OBJ_COMMIT) {
struct commit *commit = (struct commit *)o;
- if (!prefixcmp(path, "refs/heads/"))
- path = path + 11;
+ if (!prefixcmp(path, PATH_REFS_HEADS))
+ path = path + STRLEN_PATH_REFS_HEADS;
else if (data->tags_only
&& data->name_only
- && !prefixcmp(path, "refs/tags/"))
- path = path + 10;
- else if (!prefixcmp(path, "refs/"))
- path = path + 5;
+ && !prefixcmp(path, PATH_REFS_TAGS))
+ path = path + STRLEN_PATH_REFS_TAGS;
+ else if (!prefixcmp(path, PATH_REFS))
+ path = path + STRLEN_PATH_REFS;
name_rev(commit, xstrdup(path), 0, 0, deref);
}
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index 09df4e1..23b4c4e 100644
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
@@ -39,7 +39,7 @@ static int handle_one_ref(const char *path, const unsigned char *sha1,
/* Do not pack the symbolic refs */
if ((flags & REF_ISSYMREF))
return 0;
- is_tag_ref = !prefixcmp(path, "refs/tags/");
+ is_tag_ref = !prefixcmp(path, PATH_REFS_TAGS);
/* ALWAYS pack refs that were already packed or are tags */
if (!(cb->flags & PACK_REFS_ALL) && !is_tag_ref && !(flags & REF_ISPACKED))
diff --git a/builtin-push.c b/builtin-push.c
index 88c5024..2fdae7a 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -33,9 +33,9 @@ static void set_refspecs(const char **refs, int nr)
int len;
if (nr <= ++i)
die("tag shorthand without <tag>");
- len = strlen(refs[i]) + 11;
+ len = strlen(refs[i]) + STRLEN_PATH_REFS_TAGS + 1;
tag = xmalloc(len);
- strcpy(tag, "refs/tags/");
+ strcpy(tag, PATH_REFS_TAGS);
strcat(tag, refs[i]);
ref = tag;
}
@@ -148,7 +148,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(arg, "--tags")) {
- add_refspec("refs/tags/*");
+ add_refspec(PATH_REFS_TAGS "*");
continue;
}
if (!strcmp(arg, "--force") || !strcmp(arg, "-f")) {
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 4fa87f6..7e39d60 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -380,36 +380,36 @@ static int append_ref(const char *refname, const unsigned char *sha1,
static int append_head_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
{
unsigned char tmp[20];
- int ofs = 11;
- if (prefixcmp(refname, "refs/heads/"))
+ int ofs = STRLEN_PATH_REFS_HEADS;
+ if (prefixcmp(refname, PATH_REFS_HEADS))
return 0;
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
if (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1))
- ofs = 5;
+ ofs = STRLEN_PATH_REFS;
return append_ref(refname + ofs, sha1, 0);
}
static int append_remote_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
{
unsigned char tmp[20];
- int ofs = 13;
- if (prefixcmp(refname, "refs/remotes/"))
+ int ofs = STRLEN_PATH_REFS_REMOTES;
+ if (prefixcmp(refname, PATH_REFS_REMOTES))
return 0;
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
if (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1))
- ofs = 5;
+ ofs = STRLEN_PATH_REFS;
return append_ref(refname + ofs, sha1, 0);
}
static int append_tag_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
{
- if (prefixcmp(refname, "refs/tags/"))
+ if (prefixcmp(refname, PATH_REFS_TAGS))
return 0;
- return append_ref(refname + 5, sha1, 0);
+ return append_ref(refname + STRLEN_PATH_REFS, sha1, 0);
}
static const char *match_ref_pattern = NULL;
@@ -438,9 +438,9 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i
return 0;
if (fnmatch(match_ref_pattern, tail, 0))
return 0;
- if (!prefixcmp(refname, "refs/heads/"))
+ if (!prefixcmp(refname, PATH_REFS_HEADS))
return append_head_ref(refname, sha1, flag, cb_data);
- if (!prefixcmp(refname, "refs/tags/"))
+ if (!prefixcmp(refname, PATH_REFS_TAGS))
return append_tag_ref(refname, sha1, flag, cb_data);
return append_ref(refname, sha1, 0);
}
@@ -465,12 +465,12 @@ static int rev_is_head(char *head, int headlen, char *name,
if ((!head[0]) ||
(head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
return 0;
- if (!prefixcmp(head, "refs/heads/"))
- head += 11;
- if (!prefixcmp(name, "refs/heads/"))
- name += 11;
- else if (!prefixcmp(name, "heads/"))
- name += 6;
+ if (!prefixcmp(head, PATH_REFS_HEADS))
+ head += STRLEN_PATH_REFS_HEADS;
+ if (!prefixcmp(name, PATH_REFS_HEADS))
+ name += STRLEN_PATH_REFS_HEADS;
+ else if (!prefixcmp(name, PATH_HEADS))
+ name += STRLEN_PATH_HEADS;
return !strcmp(head, name);
}
@@ -781,7 +781,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
has_head++;
}
if (!has_head) {
- int pfxlen = strlen("refs/heads/");
+ int pfxlen = STRLEN_PATH_REFS_HEADS;
append_one_rev(head + pfxlen);
}
}
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index 65051d1..d463d80 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -29,8 +29,8 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo
if (tags_only || heads_only) {
int match;
- match = heads_only && !prefixcmp(refname, "refs/heads/");
- match |= tags_only && !prefixcmp(refname, "refs/tags/");
+ match = heads_only && !prefixcmp(refname, PATH_REFS_HEADS);
+ match |= tags_only && !prefixcmp(refname, PATH_REFS_TAGS);
if (!match)
return 0;
}
@@ -227,7 +227,7 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
while (*pattern) {
unsigned char sha1[20];
- if (!prefixcmp(*pattern, "refs/") &&
+ if (!prefixcmp(*pattern, PATH_REFS) &&
resolve_ref(*pattern, sha1, 1, NULL)) {
if (!quiet)
show_one(*pattern, sha1);
diff --git a/builtin-tag.c b/builtin-tag.c
index 3a9d2ee..800e823 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -146,7 +146,7 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn)
unsigned char sha1[20];
for (p = argv; *p; p++) {
- if (snprintf(ref, sizeof(ref), "refs/tags/%s", *p)
+ if (snprintf(ref, sizeof(ref), PATH_REFS_TAGS"%s", *p)
>= sizeof(ref)) {
error("tag name too long: %.*s...", 50, *p);
had_error = 1;
@@ -440,7 +440,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (get_sha1(object_ref, object))
die("Failed to resolve '%s' as a valid ref.", object_ref);
- if (snprintf(ref, sizeof(ref), "refs/tags/%s", tag) > sizeof(ref) - 1)
+ if (snprintf(ref, sizeof(ref), PATH_REFS_TAGS "%s", tag) > sizeof(ref) - 1)
die("tag name too long: %.*s...", 50, tag);
if (check_ref_format(ref))
die("'%s' is not a valid tag name.", tag);
diff --git a/connect.c b/connect.c
index 8b1e993..9d576bc 100644
--- a/connect.c
+++ b/connect.c
@@ -13,23 +13,23 @@ static int check_ref(const char *name, int len, unsigned int flags)
if (!flags)
return 1;
- if (len < 5 || memcmp(name, "refs/", 5))
+ if (len < STRLEN_PATH_REFS || memcmp(name, PATH_REFS, STRLEN_PATH_REFS))
return 0;
/* Skip the "refs/" part */
- name += 5;
- len -= 5;
+ name += STRLEN_PATH_REFS;
+ len -= STRLEN_PATH_REFS;
/* REF_NORMAL means that we don't want the magic fake tag refs */
if ((flags & REF_NORMAL) && check_ref_format(name) < 0)
return 0;
/* REF_HEADS means that we want regular branch heads */
- if ((flags & REF_HEADS) && !memcmp(name, "heads/", 6))
+ if ((flags & REF_HEADS) && !memcmp(name, PATH_HEADS, STRLEN_PATH_HEADS))
return 1;
/* REF_TAGS means that we want tags */
- if ((flags & REF_TAGS) && !memcmp(name, "tags/", 5))
+ if ((flags & REF_TAGS) && !memcmp(name, PATH_TAGS, STRLEN_PATH_TAGS))
return 1;
/* All type bits clear means that we are ok with anything */
diff --git a/fetch-pack.c b/fetch-pack.c
index 9c81305..c3b7ef6 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -344,11 +344,11 @@ static void filter_refs(struct ref **refs, int nr_match, char **match)
for (ref = *refs; ref; ref = next) {
next = ref->next;
- if (!memcmp(ref->name, "refs/", 5) &&
- check_ref_format(ref->name + 5))
+ if (!memcmp(ref->name, PATH_REFS, STRLEN_PATH_REFS) &&
+ check_ref_format(ref->name + STRLEN_PATH_REFS))
; /* trash */
else if (fetch_all &&
- (!depth || prefixcmp(ref->name, "refs/tags/") )) {
+ (!depth || prefixcmp(ref->name, PATH_REFS_TAGS) )) {
*newtail = ref;
ref->next = NULL;
newtail = &ref->next;
diff --git a/http-fetch.c b/http-fetch.c
index 202fae0..6dc32e8 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -3,6 +3,7 @@
#include "pack.h"
#include "fetch.h"
#include "http.h"
+#include "refs.h"
#define PREV_BUF_SIZE 4096
#define RANGE_HEADER_SIZE 30
@@ -157,11 +158,11 @@ static void start_object_request(struct object_request *obj_req)
SHA1_Init(&obj_req->c);
- url = xmalloc(strlen(obj_req->repo->base) + 51);
- obj_req->url = xmalloc(strlen(obj_req->repo->base) + 51);
+ url = xmalloc(strlen(obj_req->repo->base) + STRLEN_PATH_OBJECTS + 43);
+ obj_req->url = xmalloc(strlen(obj_req->repo->base) + STRLEN_PATH_OBJECTS + 43);
strcpy(url, obj_req->repo->base);
posn = url + strlen(obj_req->repo->base);
- strcpy(posn, "/objects/");
+ strcpy(posn, "/" PATH_OBJECTS);
posn += 9;
memcpy(posn, hex, 2);
posn += 2;
@@ -398,8 +399,8 @@ static int fetch_index(struct alt_base *repo, unsigned char *sha1)
if (get_verbosely)
fprintf(stderr, "Getting index for pack %s\n", hex);
- url = xmalloc(strlen(repo->base) + 64);
- sprintf(url, "%s/objects/pack/pack-%s.idx", repo->base, hex);
+ url = xmalloc(strlen(repo->base) + STRLEN_PATH_OBJECTS + 56);
+ sprintf(url, "%s/" PATH_OBJECTS "pack/pack-%s.idx", repo->base, hex);
filename = sha1_pack_index_name(sha1);
snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
@@ -478,7 +479,7 @@ static void process_alternates_response(void *callback_data)
/* Try reusing the slot to get non-http alternates */
alt_req->http_specific = 0;
- sprintf(alt_req->url, "%s/objects/info/alternates",
+ sprintf(alt_req->url, "%s/" PATH_OBJECTS "info/alternates",
base);
curl_easy_setopt(slot->curl, CURLOPT_URL,
alt_req->url);
@@ -625,8 +626,8 @@ static void fetch_alternates(const char *base)
if (get_verbosely)
fprintf(stderr, "Getting alternates list for %s\n", base);
- url = xmalloc(strlen(base) + 31);
- sprintf(url, "%s/objects/info/http-alternates", base);
+ url = xmalloc(strlen(base) + STRLEN_PATH_OBJECTS + 23);
+ sprintf(url, "%s/" PATH_OBJECTS "info/http-alternates", base);
/* Use a callback to process the result, since another request
may fail and need to have alternates loaded before continuing */
@@ -675,8 +676,8 @@ static int fetch_indices(struct alt_base *repo)
if (get_verbosely)
fprintf(stderr, "Getting pack list for %s\n", repo->base);
- url = xmalloc(strlen(repo->base) + 21);
- sprintf(url, "%s/objects/info/packs", repo->base);
+ url = xmalloc(strlen(repo->base) + STRLEN_PATH_OBJECTS + 13);
+ sprintf(url, "%s/" PATH_OBJECTS "info/packs", repo->base);
slot = get_active_slot();
slot->results = &results;
@@ -757,8 +758,8 @@ static int fetch_pack(struct alt_base *repo, unsigned char *sha1)
sha1_to_hex(sha1));
}
- url = xmalloc(strlen(repo->base) + 65);
- sprintf(url, "%s/objects/pack/pack-%s.pack",
+ url = xmalloc(strlen(repo->base) + STRLEN_PATH_OBJECTS + 57);
+ sprintf(url, "%s/" PATH_OBJECTS "pack/pack-%s.pack",
repo->base, sha1_to_hex(target->sha1));
filename = sha1_pack_name(target->sha1);
@@ -930,14 +931,14 @@ static char *quote_ref_url(const char *base, const char *ref)
int len, baselen, ch;
baselen = strlen(base);
- len = baselen + 7; /* "/refs/" + NUL */
+ len = baselen + STRLEN_PATH_REFS + 2; /* "/" + "refs/" + NUL */
for (cp = ref; (ch = *cp) != 0; cp++, len++)
if (needs_quote(ch))
len += 2; /* extra two hex plus replacement % */
qref = xmalloc(len);
memcpy(qref, base, baselen);
- memcpy(qref + baselen, "/refs/", 6);
- for (cp = ref, dp = qref + baselen + 6; (ch = *cp) != 0; cp++) {
+ memcpy(qref + baselen, PATH_REFS, STRLEN_PATH_REFS);
+ for (cp = ref, dp = qref + baselen + STRLEN_PATH_REFS; (ch = *cp) != 0; cp++) {
if (needs_quote(ch)) {
*dp++ = '%';
*dp++ = hex((ch >> 4) & 0xF);
diff --git a/http-push.c b/http-push.c
index 7c3720f..0c5e892 100644
--- a/http-push.c
+++ b/http-push.c
@@ -272,12 +272,12 @@ static void start_fetch_loose(struct transfer_request *request)
SHA1_Init(&request->c);
- url = xmalloc(strlen(remote->url) + 50);
- request->url = xmalloc(strlen(remote->url) + 50);
+ url = xmalloc(strlen(remote->url) + 42 + STRLEN_PATH_OBJECTS);
+ request->url = xmalloc(strlen(remote->url) + 42 + STRLEN_PATH_OBJECTS);
strcpy(url, remote->url);
posn = url + strlen(remote->url);
- strcpy(posn, "objects/");
- posn += 8;
+ strcpy(posn, PATH_OBJECTS);
+ posn += STRLEN_PATH_OBJECTS;
memcpy(posn, hex, 2);
posn += 2;
*(posn++) = '/';
@@ -357,11 +357,11 @@ static void start_mkcol(struct transfer_request *request)
struct active_request_slot *slot;
char *posn;
- request->url = xmalloc(strlen(remote->url) + 13);
+ request->url = xmalloc(strlen(remote->url) + STRLEN_PATH_OBJECTS + 5);
strcpy(request->url, remote->url);
posn = request->url + strlen(remote->url);
- strcpy(posn, "objects/");
- posn += 8;
+ strcpy(posn, PATH_OBJECTS);
+ posn += STRLEN_PATH_OBJECTS;
memcpy(posn, hex, 2);
posn += 2;
strcpy(posn, "/");
@@ -415,8 +415,8 @@ static void start_fetch_packed(struct transfer_request *request)
snprintf(request->tmpfile, sizeof(request->tmpfile),
"%s.temp", filename);
- url = xmalloc(strlen(remote->url) + 64);
- sprintf(url, "%sobjects/pack/pack-%s.pack",
+ url = xmalloc(strlen(remote->url) + STRLEN_PATH_OBJECTS + 56);
+ sprintf(url, "%s/" PATH_OBJECTS "pack/pack-%s.pack",
remote->url, sha1_to_hex(target->sha1));
/* Make sure there isn't another open request for this pack */
@@ -519,11 +519,11 @@ static void start_put(struct transfer_request *request)
request->buffer.posn = 0;
request->url = xmalloc(strlen(remote->url) +
- strlen(request->lock->token) + 51);
+ strlen(request->lock->token) + STRLEN_PATH_OBJECTS + 43);
strcpy(request->url, remote->url);
posn = request->url + strlen(remote->url);
- strcpy(posn, "objects/");
- posn += 8;
+ strcpy(posn, PATH_OBJECTS);
+ posn += STRLEN_PATH_OBJECTS;
memcpy(posn, hex, 2);
posn += 2;
*(posn++) = '/';
@@ -922,8 +922,8 @@ static int fetch_index(unsigned char *sha1)
struct slot_results results;
/* Don't use the index if the pack isn't there */
- url = xmalloc(strlen(remote->url) + 64);
- sprintf(url, "%sobjects/pack/pack-%s.pack", remote->url, hex);
+ url = xmalloc(strlen(remote->url) + STRLEN_PATH_OBJECTS + 56);
+ sprintf(url, "%s" PATH_OBJECTS "pack/pack-%s.pack", remote->url, hex);
slot = get_active_slot();
slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
@@ -945,7 +945,7 @@ static int fetch_index(unsigned char *sha1)
if (push_verbosely)
fprintf(stderr, "Getting index for pack %s\n", hex);
- sprintf(url, "%sobjects/pack/pack-%s.idx", remote->url, hex);
+ sprintf(url, "%s" PATH_OBJECTS "/pack/pack-%s.idx", remote->url, hex);
filename = sha1_pack_index_name(sha1);
snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
@@ -1029,8 +1029,8 @@ static int fetch_indices(void)
if (push_verbosely)
fprintf(stderr, "Getting pack list\n");
- url = xmalloc(strlen(remote->url) + 20);
- sprintf(url, "%sobjects/info/packs", remote->url);
+ url = xmalloc(strlen(remote->url) + STRLEN_PATH_OBJECTS + 12);
+ sprintf(url, "%s" PATH_OBJECTS "info/packs", remote->url);
slot = get_active_slot();
slot->results = &results;
@@ -1615,7 +1615,7 @@ static void remote_ls(const char *path, int flags,
static void get_remote_object_list(unsigned char parent)
{
- char path[] = "objects/XX/";
+ char path[] = PATH_OBJECTS "XX/";
static const char hex[] = "0123456789abcdef";
unsigned int val = parent;
@@ -1925,7 +1925,7 @@ static void get_local_heads(void)
static void get_dav_remote_heads(void)
{
remote_tail = &remote_refs;
- remote_ls("refs/", (PROCESS_FILES | PROCESS_DIRS | RECURSIVE), process_ls_ref, NULL);
+ remote_ls(PATH_REFS, (PROCESS_FILES | PROCESS_DIRS | RECURSIVE), process_ls_ref, NULL);
}
static int is_zero_sha1(const unsigned char *sha1)
@@ -2069,7 +2069,7 @@ static void update_remote_info_refs(struct remote_lock *lock)
buffer.buffer = xcalloc(1, 4096);
buffer.size = 4096;
buffer.posn = 0;
- remote_ls("refs/", (PROCESS_FILES | RECURSIVE),
+ remote_ls(PATH_REFS, (PROCESS_FILES | RECURSIVE),
add_remote_info_ref, &buffer);
if (!aborted) {
if_header = xmalloc(strlen(lock->token) + 25);
@@ -2375,7 +2375,7 @@ int main(int argc, char **argv)
/* Check whether the remote has server info files */
remote->can_update_info_refs = 0;
remote->has_info_refs = remote_exists("info/refs");
- remote->has_info_packs = remote_exists("objects/info/packs");
+ remote->has_info_packs = remote_exists(PATH_OBJECTS "info/packs");
if (remote->has_info_refs) {
info_ref_lock = lock_remote("info/refs", LOCK_TIME);
if (info_ref_lock)
diff --git a/local-fetch.c b/local-fetch.c
index bf7ec6c..67dc065 100644
--- a/local-fetch.c
+++ b/local-fetch.c
@@ -4,6 +4,7 @@
#include "cache.h"
#include "commit.h"
#include "fetch.h"
+#include "refs.h"
static int use_link;
static int use_symlink;
@@ -23,7 +24,7 @@ static void setup_index(unsigned char *sha1)
struct packed_git *new_pack;
char filename[PATH_MAX];
strcpy(filename, path);
- strcat(filename, "/objects/pack/pack-");
+ strcat(filename, "/" PATH_OBJECTS "pack/pack-");
strcat(filename, sha1_to_hex(sha1));
strcat(filename, ".idx");
new_pack = parse_pack_index_file(sha1, filename);
@@ -37,7 +38,7 @@ static int setup_indices(void)
struct dirent *de;
char filename[PATH_MAX];
unsigned char sha1[20];
- sprintf(filename, "%s/objects/pack/", path);
+ sprintf(filename, "%s/" PATH_OBJECTS "pack/", path);
dir = opendir(filename);
if (!dir)
return -1;
@@ -122,11 +123,11 @@ static int fetch_pack(const unsigned char *sha1)
fprintf(stderr, " which contains %s\n",
sha1_to_hex(sha1));
}
- sprintf(filename, "%s/objects/pack/pack-%s.pack",
+ sprintf(filename, "%s/" PATH_OBJECTS "pack/pack-%s.pack",
path, sha1_to_hex(target->sha1));
copy_file(filename, sha1_pack_name(target->sha1),
sha1_to_hex(target->sha1), 1);
- sprintf(filename, "%s/objects/pack/pack-%s.idx",
+ sprintf(filename, "%s/" PATH_OBJECTS "pack/pack-%s.idx",
path, sha1_to_hex(target->sha1));
copy_file(filename, sha1_pack_index_name(target->sha1),
sha1_to_hex(target->sha1), 1);
@@ -143,7 +144,7 @@ static int fetch_file(const unsigned char *sha1)
if (object_name_start < 0) {
strcpy(filename, path); /* e.g. git.git */
- strcat(filename, "/objects/");
+ strcat(filename, "/" PATH_OBJECTS);
object_name_start = strlen(filename);
}
filename[object_name_start+0] = hex[0];
@@ -169,7 +170,7 @@ int fetch_ref(char *ref, unsigned char *sha1)
int ifd;
if (ref_name_start < 0) {
- sprintf(filename, "%s/refs/", path);
+ sprintf(filename, "%s/" PATH_REFS, path);
ref_name_start = strlen(filename);
}
strcpy(filename + ref_name_start, ref);
diff --git a/path.c b/path.c
index 4260952..78511d7 100644
--- a/path.c
+++ b/path.c
@@ -11,6 +11,7 @@
* which is what it's designed for.
*/
#include "cache.h"
+#include "refs.h"
static char bad_path[] = "/bad-path/";
@@ -99,7 +100,7 @@ int validate_headref(const char *path)
/* Make sure it is a "refs/.." symlink */
if (S_ISLNK(st.st_mode)) {
len = readlink(path, buffer, sizeof(buffer)-1);
- if (len >= 5 && !memcmp("refs/", buffer, 5))
+ if (len >= 5 && !memcmp(PATH_REFS, buffer, STRLEN_PATH_REFS))
return 0;
return -1;
}
@@ -123,7 +124,7 @@ int validate_headref(const char *path)
len -= 4;
while (len && isspace(*buf))
buf++, len--;
- if (len >= 5 && !memcmp("refs/", buf, 5))
+ if (len >= STRLEN_PATH_REFS && !memcmp(PATH_REFS, buf, STRLEN_PATH_REFS))
return 0;
}
diff --git a/receive-pack.c b/receive-pack.c
index d3c422b..114ea38 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -165,7 +165,7 @@ static const char *update(struct command *cmd)
unsigned char *new_sha1 = cmd->new_sha1;
struct ref_lock *lock;
- if (!prefixcmp(name, "refs/") && check_ref_format(name + 5)) {
+ if (!prefixcmp(name, PATH_REFS) && check_ref_format(name + STRLEN_PATH_REFS)) {
error("refusing to create funny ref '%s' locally", name);
return "funny refname";
}
@@ -177,7 +177,7 @@ static const char *update(struct command *cmd)
}
if (deny_non_fast_forwards && !is_null_sha1(new_sha1) &&
!is_null_sha1(old_sha1) &&
- !prefixcmp(name, "refs/heads/")) {
+ !prefixcmp(name, PATH_REFS_HEADS)) {
struct commit *old_commit, *new_commit;
struct commit_list *bases, *ent;
diff --git a/reflog-walk.c b/reflog-walk.c
index ee1456b..98cf8ef 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -55,11 +55,11 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)
}
if (reflogs->nr == 0) {
int len = strlen(ref);
- char *refname = xmalloc(len + 12);
- sprintf(refname, "refs/%s", ref);
+ char *refname = xmalloc(len + STRLEN_PATH_REFS_HEADS + 1);
+ sprintf(refname, PATH_REFS "%s", ref);
for_each_reflog_ent(refname, read_one_reflog, reflogs);
if (reflogs->nr == 0) {
- sprintf(refname, "refs/heads/%s", ref);
+ sprintf(refname, PATH_REFS_HEADS "%s", ref);
for_each_reflog_ent(refname, read_one_reflog, reflogs);
}
free(refname);
diff --git a/refs.c b/refs.c
index 7fb3350..840a433 100644
--- a/refs.c
+++ b/refs.c
@@ -409,7 +409,7 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
/* Follow "normalized" - ie "refs/.." symlinks by hand */
if (S_ISLNK(st.st_mode)) {
len = readlink(path, buffer, sizeof(buffer)-1);
- if (len >= 5 && !memcmp("refs/", buffer, 5)) {
+ if (len >= STRLEN_PATH_REFS && !memcmp(PATH_REFS, buffer, STRLEN_PATH_REFS)) {
buffer[len] = 0;
strcpy(ref_buffer, buffer);
ref = ref_buffer;
@@ -561,22 +561,22 @@ int head_ref(each_ref_fn fn, void *cb_data)
int for_each_ref(each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref("refs/", fn, 0, cb_data);
+ return do_for_each_ref(PATH_REFS, fn, 0, cb_data);
}
int for_each_tag_ref(each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref("refs/tags/", fn, 10, cb_data);
+ return do_for_each_ref(PATH_REFS_TAGS, fn, STRLEN_PATH_REFS_TAGS, cb_data);
}
int for_each_branch_ref(each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref("refs/heads/", fn, 11, cb_data);
+ return do_for_each_ref(PATH_REFS_HEADS, fn, STRLEN_PATH_REFS_HEADS, cb_data);
}
int for_each_remote_ref(each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref("refs/remotes/", fn, 13, cb_data);
+ return do_for_each_ref(PATH_REFS_REMOTES, fn, STRLEN_PATH_REFS_REMOTES, cb_data);
}
/* NEEDSWORK: This is only used by ssh-upload and it should go; the
@@ -588,7 +588,7 @@ int get_ref_sha1(const char *ref, unsigned char *sha1)
{
if (check_ref_format(ref))
return -1;
- return read_ref(mkpath("refs/%s", ref), sha1);
+ return read_ref(mkpath(PATH_REFS "%s", ref), sha1);
}
/*
@@ -824,7 +824,7 @@ struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
char refpath[PATH_MAX];
if (check_ref_format(ref))
return NULL;
- strcpy(refpath, mkpath("refs/%s", ref));
+ strcpy(refpath, mkpath(PATH_REFS "%s", ref));
return lock_ref_sha1_basic(refpath, old_sha1, 0, NULL);
}
@@ -1078,8 +1078,8 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
log_file = git_path("logs/%s", ref_name);
if (log_all_ref_updates &&
- (!prefixcmp(ref_name, "refs/heads/") ||
- !prefixcmp(ref_name, "refs/remotes/") ||
+ (!prefixcmp(ref_name, PATH_REFS_HEADS) ||
+ !prefixcmp(ref_name, PATH_REFS_REMOTES) ||
!strcmp(ref_name, "HEAD"))) {
if (safe_create_leading_directories(log_file) < 0)
return error("unable to create directory for %s",
diff --git a/refs.h b/refs.h
index 6eb98a4..1025d04 100644
--- a/refs.h
+++ b/refs.h
@@ -13,6 +13,23 @@ struct ref_lock {
#define REF_ISSYMREF 01
#define REF_ISPACKED 02
+#define PATH_OBJECTS "objects/"
+#define STRLEN_PATH_OBJECTS 8
+#define PATH_REFS "refs/"
+#define STRLEN_PATH_REFS 5
+#define PATH_HEADS "heads/"
+#define STRLEN_PATH_HEADS 6
+#define PATH_TAGS "tags/"
+#define STRLEN_PATH_TAGS 5
+#define PATH_REMOTES "remotes/"
+#define STRLEN_PATH_REMOTES 8
+#define PATH_REFS_HEADS PATH_REFS PATH_HEADS
+#define STRLEN_PATH_REFS_HEADS (STRLEN_PATH_REFS+STRLEN_PATH_HEADS)
+#define PATH_REFS_TAGS PATH_REFS PATH_TAGS
+#define STRLEN_PATH_REFS_TAGS (STRLEN_PATH_REFS+STRLEN_PATH_TAGS)
+#define PATH_REFS_REMOTES PATH_REFS PATH_REMOTES
+#define STRLEN_PATH_REFS_REMOTES (STRLEN_PATH_REFS+STRLEN_PATH_REMOTES)
+
/*
* Calls the specified function for each ref file until it returns nonzero,
* and returns the value
diff --git a/remote.c b/remote.c
index bb774d0..8d1e0a4 100644
--- a/remote.c
+++ b/remote.c
@@ -211,8 +211,8 @@ static void read_config(void)
current_branch = NULL;
head_ref = resolve_ref("HEAD", sha1, 0, &flag);
if (head_ref && (flag & REF_ISSYMREF) &&
- !prefixcmp(head_ref, "refs/heads/")) {
- current_branch = head_ref + strlen("refs/heads/");
+ !prefixcmp(head_ref, PATH_REFS_HEADS)) {
+ current_branch = head_ref + strlen(PATH_REFS_HEADS);
current_branch_len = strlen(current_branch);
}
git_config(handle_config);
@@ -398,9 +398,9 @@ static int count_refspec_match(const char *pattern,
* at the remote site.
*/
if (namelen != patlen &&
- patlen != namelen - 5 &&
- prefixcmp(name, "refs/heads/") &&
- prefixcmp(name, "refs/tags/")) {
+ patlen != namelen - STRLEN_PATH_REFS_HEADS &&
+ prefixcmp(name, PATH_REFS_HEADS) &&
+ prefixcmp(name, PATH_REFS_HEADS)) {
/* We want to catch the case where only weak
* matches are found and there are multiple
* matches, and where more than one strong
@@ -511,7 +511,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
case 1:
break;
case 0:
- if (!memcmp(dst_value, "refs/", 5))
+ if (!prefixcmp(dst_value, PATH_REFS))
matched_dst = make_linked_ref(dst_value, dst_tail);
else
error("dst refspec %s does not match any "
@@ -594,7 +594,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
if (!pat)
continue;
}
- else if (prefixcmp(src->name, "refs/heads/"))
+ else if (prefixcmp(src->name, PATH_REFS_HEADS))
/*
* "matching refs"; traditionally we pushed everything
* including refs outside refs/heads/ hierarchy, but
diff --git a/setup.c b/setup.c
index 06004f1..c8912d2 100644
--- a/setup.c
+++ b/setup.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "dir.h"
+#include "refs.h"
static int inside_git_dir = -1;
static int inside_work_tree = -1;
@@ -158,12 +159,12 @@ static int is_git_directory(const char *suspect)
return 0;
}
else {
- strcpy(path + len, "/objects");
+ strcpy(path + len, "/" PATH_OBJECTS);
if (access(path, X_OK))
return 0;
}
- strcpy(path + len, "/refs");
+ strcpy(path + len, "/" PATH_REFS);
if (access(path, X_OK))
return 0;
diff --git a/sha1_name.c b/sha1_name.c
index 2d727d5..649e438 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -241,11 +241,11 @@ static int ambiguous_path(const char *path, int len)
static const char *ref_fmt[] = {
"%.*s",
- "refs/%.*s",
- "refs/tags/%.*s",
- "refs/heads/%.*s",
- "refs/remotes/%.*s",
- "refs/remotes/%.*s/HEAD",
+ PATH_REFS "%.*s",
+ PATH_REFS_TAGS "%.*s",
+ PATH_REFS_HEADS "%.*s",
+ PATH_REFS_REMOTES "%.*s",
+ PATH_REFS_REMOTES "%.*s/HEAD",
NULL
};
diff --git a/wt-status.c b/wt-status.c
index 10ce6ee..93dee72 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -7,6 +7,7 @@
#include "diff.h"
#include "revision.h"
#include "diffcore.h"
+#include "refs.h"
int wt_status_use_color = 0;
static char wt_status_colors[][COLOR_MAXLEN] = {
@@ -311,8 +312,8 @@ void wt_status_print(struct wt_status *s)
if (s->branch) {
const char *on_what = "On branch ";
const char *branch_name = s->branch;
- if (!prefixcmp(branch_name, "refs/heads/"))
- branch_name += 11;
+ if (!prefixcmp(branch_name, PATH_REFS_HEADS))
+ branch_name += STRLEN_PATH_REFS_HEADS;
else if (!strcmp(branch_name, "HEAD")) {
branch_name = "";
on_what = "Not currently on any branch.";
--
1.5.3.rc5.11.g312e
^ permalink raw reply related
* Re: [PATCH 1/1] --color and --no-color git-log options don't need diffs to be computed.
From: Pierre Habouzit @ 2007-09-29 12:56 UTC (permalink / raw)
To: David Kastrup; +Cc: Junio C Hamano, git
In-Reply-To: <85ve9t8wh7.fsf@lola.goethe.zz>
[-- Attachment #1: Type: text/plain, Size: 704 bytes --]
On Sat, Sep 29, 2007 at 12:52:36PM +0000, David Kastrup wrote:
> Pierre Habouzit <madcoder@debian.org> writes:
>
> > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
>
> > - if (strcmp(argv[i], "-z"))
> > - revs->diff = 1;
> > + revs->diff = strcmp(argv[i], "-z")
> > + && strcmp(argv[i], "--color")
> > + && strcmp(argv[i], "--no-color");
> > i += opts - 1;
> > continue;
>
> This can clear a previously set value of revs->diff.
Good catch, that should be |= of course.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* Re: [PATCH 1/1] --color and --no-color git-log options don't need diffs to be computed.
From: David Kastrup @ 2007-09-29 12:52 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: Junio C Hamano, git
In-Reply-To: <20070929123724.01BB045EC@madism.org>
Pierre Habouzit <madcoder@debian.org> writes:
> Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> - if (strcmp(argv[i], "-z"))
> - revs->diff = 1;
> + revs->diff = strcmp(argv[i], "-z")
> + && strcmp(argv[i], "--color")
> + && strcmp(argv[i], "--no-color");
> i += opts - 1;
> continue;
This can clear a previously set value of revs->diff.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply
* Re: [PATCH] handle Docbook XSL 1.72 (incompletely)
From: Miklos Vajna @ 2007-09-29 12:48 UTC (permalink / raw)
To: Alexey Mahotkin; +Cc: git
In-Reply-To: <bb5b640b0709201426u6ab77d07n6039499eb8baf381@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 921 bytes --]
On Fri, Sep 21, 2007 at 01:26:21AM +0400, Alexey Mahotkin <squadette@gmail.com> wrote:
> Fedora Core 7 has docbook-style-xsl-1.72.0-2.fc7
>
> git-diff manpage (and couple of more, using callouts) is broken here:
>
> EXAMPLES
> Various ways to check your working tree
>
> $ git diff \fB(1)\fR
> $ git diff --cached \fB(2)\fR
> $ git diff HEAD \fB(3)\fR
>
> .sp \fB1. \fRChanges in the working tree not yet staged for
> the next commit.
this is a bug in docbook-xsl. see
http://article.gmane.org/gmane.comp.version-control.git/54785
by the way, are gitlinks okay at you?
example: in the DESCRIPTION section:
"You can stage these changes by using git1[1]."
while the man branch has:
"You can stage these changes by using git-add(1)."
this is asciidoc 8.2.3 and docbook-xsl 1.73.2
thanks,
- VMiklos
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox