* Re: Git 1.3.2 on Solaris
From: Stefan Pfetzing @ 2006-05-17 9:06 UTC (permalink / raw)
To: Git Mailing List
In-Reply-To: <7vpsidhx79.fsf@assigned-by-dhcp.cox.net>
Hi Junio,
2006/5/17, Junio C Hamano <junkio@cox.net>:
> "Stefan Pfetzing" <stefan.pfetzing@gmail.com> writes:
>
> > 1. fix every single shellscript automatically during the build phase
> > 2. setup a dir which contains symlinks to the "right" binaries and
> > put that dir into PATH.
>
> You forgot 3.
>
> 3. rewrite scripts so that they would require only POSIX;
> for ones that do need GNU extended coreutils to do in
> shell, find other ways, perhaps rewriting the stuff in C.
Yes, thats right, but this can only be a long term goal, because I guess
this will take significantly longer. - even "tr" and "diff" behave different
on Solaris.
> I am not looking forward to do the g- prefix in the main
> Makefile. The approach to have symlink forest under gitexecdir
> (<Pine.LNX.4.64.0605162047380.10823@g5.osdl.org> by Linus) is
> more palatable, and I am not opposed to host a script to do so
> under contrib/notgnu perhaps.
Hm, gitexecdir is also the path where git is installed, right? So if I'd
install git with pkgsrc it will be /usr/pkg/bin, right? - If so,
putting symlinks
there _will_ break pkgsrc.
bye
Stefan
--
http://www.dreamind.de/
Oroborus and Debian GNU/Linux Developer.
^ permalink raw reply
* Re: Git 1.3.2 on Solaris
From: Junio C Hamano @ 2006-05-17 9:03 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0605161904260.16475@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> [ Junio - see the "grep" issue ]
> ...
> Of course, I don't think anybody tried the new "git grep" on Solaris,...
I haven't tried the new grep on Solaris myself, as the Solaris
box I have easy access is badly maintained (unmaintained is
probably a better wording).
> ...and
> I think the solaris "grep" lacks the "-H" flag, for example. But that
> should be easy to fix (for example, replace the use of "--" and "-H" with
> putting a "/dev/null" as the first filename).
You mean like this, I presume.
But I think this approach breaks -L; I do not think Solaris
supports -L, so it does not matter there, but on platforms that
knows how to do -L it does.
-- >8 --
[PATCH] builtin-grep: give /dev/null at the beginning instead of -H
---
diff --git a/builtin-grep.c b/builtin-grep.c
index 66111de..ff3c1f7 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -453,7 +453,6 @@ static int external_grep(struct grep_opt
len = nr = 0;
push_arg("grep");
- push_arg("-H");
if (opt->fixed)
push_arg("-F");
if (opt->linenum)
@@ -503,7 +502,7 @@ static int external_grep(struct grep_opt
push_arg("-e");
push_arg(p->pattern);
}
- push_arg("--");
+ push_arg("/dev/null");
hit = 0;
argc = nr;
^ permalink raw reply related
* Re: Merge with local conflicts in new files
From: Martin Langhoff @ 2006-05-17 8:50 UTC (permalink / raw)
To: Pavel Roskin; +Cc: Junio C Hamano, Santi, git
In-Reply-To: <1147852052.31879.50.camel@dv>
On 5/17/06, Pavel Roskin <proski@gnu.org> wrote:
> If a file doesn't "belong" to git, it belongs to its
> "supreme commander", i.e. the user, and should be approached with utmost
> care.
+1 here. Unknown files are precious (to take an Arch term) until git
is told otherwise.
> special options (e.g. --force or --hard), and for the files explicitly
> marked as transient (e.g. in .gitignore).
I think that if we turn into clobbering files listed in .gitignore
users will probably be screaming bloody murder. No git op should
clobber untracked files...
Arch has this strange concept of allowing you to list 'junk' files. I
could never figure out why it would want my authorization to remove
files randomly. For all its faults, cvs does the right thing -- it
will say 'checkout/update of foo.c blocked by foo.c in directory'. And
if you force it with -C it will rename the local file to
.#originalname-local or something like that.
Even the files I think of as junk are actually useful and should not
be messed up with. Editor temp files, for instance, are often listed
in .gitignore, and if you ask me, they are junk. Except while I am
working with my editor! ;-)
Another case is .project files from IDEs like Eclipse. People list
them in .cvsignore so that they are not committed, and yet preserved.
The user probably has a lot of personal settings there.
cheers,
martin
^ permalink raw reply
* Re: Fwd: [OT] Re: Git via a proxy server?
From: Jan-Benedict Glaw @ 2006-05-17 8:38 UTC (permalink / raw)
To: Sam Song; +Cc: Petr Vandrovec, git
In-Reply-To: <20060517035639.40450.qmail@web32004.mail.mud.yahoo.com>
[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]
On Tue, 2006-05-16 20:56:39 -0700, Sam Song <samlinuxkernel@yahoo.com> wrote:
> Petr Vandrovec <petr@vmware.com> wrote:
> > Best to test this is to start 'socket 192.168.40.99
> > 80' from command line and
> > then type these two lines above, plus one empty
> > line. You should get back '200
> > OK', empty line, and then you can start
> > communicating using git protocol - if
> > you can do that...
>
> I cannot run "socket" and "CONNECT" on Fedora Core 3.
> It simply told me that no such command. How could I
> do this task in my case?
Well, install some package to have `socket' available? Debian calls
the packet `socket', too, so I guess Fedora may have something
similar.
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
für einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* Re: Git 1.3.2 on Solaris
From: Junio C Hamano @ 2006-05-17 8:28 UTC (permalink / raw)
To: Stefan Pfetzing; +Cc: git
In-Reply-To: <f3d7535d0605161652n3b2ec033r874336082755e728@mail.gmail.com>
"Stefan Pfetzing" <stefan.pfetzing@gmail.com> writes:
> 1. fix every single shellscript automatically during the build phase
> 2. setup a dir which contains symlinks to the "right" binaries and
> put that dir into PATH.
You forgot 3.
3. rewrite scripts so that they would require only POSIX;
for ones that do need GNU extended coreutils to do in
shell, find other ways, perhaps rewriting the stuff in C.
I am not looking forward to do the g- prefix in the main
Makefile. The approach to have symlink forest under gitexecdir
(<Pine.LNX.4.64.0605162047380.10823@g5.osdl.org> by Linus) is
more palatable, and I am not opposed to host a script to do so
under contrib/notgnu perhaps.
^ permalink raw reply
* Re: [PATCH/RFC] read-tree -m -u: do not overwrite or remove untracked working tree files.
From: Jakub Narebski @ 2006-05-17 8:24 UTC (permalink / raw)
To: git
In-Reply-To: <7v8xp1jc9h.fsf_-_@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
> This is an RFC patch that I consider of somewhat dubious value.
> Not the implementation quality, but the semantic change it
> implies. Before, we could freely work in a working tree, which
> is just a scratch area to build the index, littered with
> throw-away files, knowing they would not prevent merge between
> our HEAD and other branch from happenning even if a merge needs
> to blow them away. With this change, it is not a case anymore.
> Your merge will fail to proceed and you have to remove those
> throw-away files yourself and retry the merge. The extent of
> the damage can be seen by the change to t1002 test this commit
> contains. It arguably is making things much safer by refusing to
> proceed, so this might be a desirable change. I am still
> undecided.
Perhaps the behavior should be decided by the config option, e.g.
core.preserveWorkingTree; of course that leave us with the problem what
value should be the default: the one preserving backward compatibility, or
the more safe one.
And of course --force to blow away changes anyway...
--
Jakub Narebski
Warsaw, Poland
^ permalink raw reply
* Re: Git 1.3.2 on Solaris
From: Junio C Hamano @ 2006-05-17 8:22 UTC (permalink / raw)
To: Ryan Anderson; +Cc: git
In-Reply-To: <20060517051505.GD31164@h4x0r5.com>
Ryan Anderson <ryan@michonline.com> writes:
> The only major tool I can think of that has embedded Perl in the shell
> script is format-patch. That could probably be redone in pure Perl if
> it would help.
Actually, that one is in the process of migrating all C.
^ permalink raw reply
* Re: Merge with local conflicts in new files
From: Junio C Hamano @ 2006-05-17 8:20 UTC (permalink / raw)
To: Pavel Roskin; +Cc: git
In-Reply-To: <1147852052.31879.50.camel@dv>
Pavel Roskin <proski@gnu.org> writes:
> I'm afraid this approach, while understandable from the technical
> standpoint, could prevent git from ever becoming a version control
> system that "just works" without any porcelains.
>
> I know a person who refuses to use any version control. If he
> encountered this situation, he would never try any version control
> again.
>
> After all, we are talking about files in the _working_ directory. It's
> not merely a transient appendix to the repository. git is not the only
> player here. If a file doesn't "belong" to git, it belongs to its
> "supreme commander", i.e. the user, and should be approached with utmost
> care.
I am biased ;-) and appreciate corrections like this. How does
the updated patch I just sent out look?
^ permalink raw reply
* [PATCH/RFC] read-tree -m -u: do not overwrite or remove untracked working tree files.
From: Junio C Hamano @ 2006-05-17 8:17 UTC (permalink / raw)
To: Santi; +Cc: git
In-Reply-To: <8aa486160605161611p4c9ddbc0v@mail.gmail.com>
When a merge results in a creation of a path that did not exist
in HEAD, and if you already have that path on the working tree,
because the index has not been told about the working tree file,
read-tree happily removes it. The issue was brought up by Santi
Béjar on the list.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
>> This is totally untested, but on top of "next" you could do
>> something like this, perhaps.
>
> Thanks, it works here.
This is an updated version, applicable to the "master" branch.
The earlier one only dealt with very limited cases, and I
suspect it did not do the right thing when "--reset" is
involved (it would probably had broken "git reset --hard").
This is an RFC patch that I consider of somewhat dubious value.
Not the implementation quality, but the semantic change it
implies. Before, we could freely work in a working tree, which
is just a scratch area to build the index, littered with
throw-away files, knowing they would not prevent merge between
our HEAD and other branch from happenning even if a merge needs
to blow them away. With this change, it is not a case anymore.
Your merge will fail to proceed and you have to remove those
throw-away files yourself and retry the merge. The extent of
the damage can be seen by the change to t1002 test this commit
contains. It arguably is making things much safer by refusing to
proceed, so this might be a desirable change. I am still
undecided.
435ac2bfd2ef29c584531cd4a29c1f018f9aea13
read-tree.c | 43 ++++++++++++++++++++++++---
t/t1002-read-tree-m-u-2way.sh | 66 +++++++++++++++++++++++++++--------------
t/t3500-cherry.sh | 1 +
t/t4002-diff-basic.sh | 6 ++--
t/t6022-merge-rename.sh | 1 +
5 files changed, 87 insertions(+), 30 deletions(-)
435ac2bfd2ef29c584531cd4a29c1f018f9aea13
diff --git a/read-tree.c b/read-tree.c
index e16e91b..6dc95a3 100644
--- a/read-tree.c
+++ b/read-tree.c
@@ -408,7 +408,7 @@ static void verify_uptodate(struct cache
{
struct stat st;
- if (index_only)
+ if (index_only || reset)
return;
if (!lstat(ce->name, &st)) {
@@ -426,6 +426,21 @@ static void verify_uptodate(struct cache
die("Entry '%s' not uptodate. Cannot merge.", ce->name);
}
+/*
+ * We do not want to remove or overwrite a working tree file that
+ * is not tracked.
+ */
+static void verify_absent(const char *path, const char *action)
+{
+ struct stat st;
+
+ if (index_only || reset || !update)
+ return;
+ if (!lstat(path, &st))
+ die("Untracked working tree file '%s' "
+ "would be %s by merge.", path, action);
+}
+
static int merged_entry(struct cache_entry *merge, struct cache_entry *old)
{
merge->ce_flags |= htons(CE_UPDATE);
@@ -443,6 +458,9 @@ static int merged_entry(struct cache_ent
verify_uptodate(old);
}
}
+ else
+ verify_absent(merge->name, "overwritten");
+
merge->ce_flags &= ~htons(CE_STAGEMASK);
add_cache_entry(merge, ADD_CACHE_OK_TO_ADD);
return 1;
@@ -452,6 +470,8 @@ static int deleted_entry(struct cache_en
{
if (old)
verify_uptodate(old);
+ else
+ verify_absent(ce->name, "removed");
ce->ce_mode = 0;
add_cache_entry(ce, ADD_CACHE_OK_TO_ADD);
return 1;
@@ -487,6 +507,7 @@ static int threeway_merge(struct cache_e
int count;
int head_match = 0;
int remote_match = 0;
+ const char *path = NULL;
int df_conflict_head = 0;
int df_conflict_remote = 0;
@@ -498,8 +519,11 @@ static int threeway_merge(struct cache_e
for (i = 1; i < head_idx; i++) {
if (!stages[i])
any_anc_missing = 1;
- else
+ else {
+ if (!path)
+ path = stages[i]->name;
no_anc_exists = 0;
+ }
}
index = stages[0];
@@ -515,6 +539,13 @@ static int threeway_merge(struct cache_e
remote = NULL;
}
+ if (!path && index)
+ path = index->name;
+ if (!path && head)
+ path = head->name;
+ if (!path && remote)
+ path = remote->name;
+
/* First, if there's a #16 situation, note that to prevent #13
* and #14.
*/
@@ -575,6 +606,8 @@ static int threeway_merge(struct cache_e
(remote_deleted && head && head_match)) {
if (index)
return deleted_entry(index, index);
+ else if (path)
+ verify_absent(path, "removed");
return 0;
}
/*
@@ -592,6 +625,8 @@ static int threeway_merge(struct cache_e
if (index) {
verify_uptodate(index);
}
+ else if (path)
+ verify_absent(path, "overwritten");
nontrivial_merge = 1;
@@ -689,7 +724,7 @@ static int oneway_merge(struct cache_ent
merge_size);
if (!a)
- return deleted_entry(old, NULL);
+ return deleted_entry(old, old);
if (old && same(old, a)) {
if (reset) {
struct stat st;
@@ -699,7 +734,7 @@ static int oneway_merge(struct cache_ent
}
return keep_entry(old);
}
- return merged_entry(a, NULL);
+ return merged_entry(a, old);
}
static int read_cache_unmerged(void)
diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index 4d175d8..8335a63 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -39,7 +39,6 @@ test_expect_success \
echo nitfol >nitfol &&
echo bozbar >bozbar &&
echo rezrov >rezrov &&
- echo yomin >yomin &&
git-update-index --add nitfol bozbar rezrov &&
treeH=`git-write-tree` &&
echo treeH $treeH &&
@@ -56,7 +55,8 @@ test_expect_success \
test_expect_success \
'1, 2, 3 - no carry forward' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >1-3.out &&
cmp M.out 1-3.out &&
@@ -66,11 +66,12 @@ test_expect_success \
check_cache_at frotz clean &&
check_cache_at nitfol clean'
-echo '+100644 X 0 yomin' >expected
-
test_expect_success \
'4 - carry forward local addition.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
+ echo "+100644 X 0 yomin" >expected &&
+ echo yomin >yomin &&
git-update-index --add yomin &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >4.out || return 1
@@ -85,7 +86,9 @@ test_expect_success \
test_expect_success \
'5 - carry forward local addition.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
+ git-read-tree -m -u $treeH &&
echo yomin >yomin &&
git-update-index --add yomin &&
echo yomin yomin >yomin &&
@@ -103,7 +106,9 @@ test_expect_success \
test_expect_success \
'6 - local addition already has the same.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
+ echo frotz >frotz &&
git-update-index --add frotz &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >6.out &&
@@ -117,7 +122,8 @@ test_expect_success \
test_expect_success \
'7 - local addition already has the same.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo frotz >frotz &&
git-update-index --add frotz &&
echo frotz frotz >frotz &&
@@ -134,14 +140,16 @@ test_expect_success \
test_expect_success \
'8 - conflicting addition.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo frotz frotz >frotz &&
git-update-index --add frotz &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
test_expect_success \
'9 - conflicting addition.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo frotz frotz >frotz &&
git-update-index --add frotz &&
echo frotz >frotz &&
@@ -149,7 +157,8 @@ test_expect_success \
test_expect_success \
'10 - path removed.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo rezrov >rezrov &&
git-update-index --add rezrov &&
git-read-tree -m -u $treeH $treeM &&
@@ -160,7 +169,8 @@ test_expect_success \
test_expect_success \
'11 - dirty path removed.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo rezrov >rezrov &&
git-update-index --add rezrov &&
echo rezrov rezrov >rezrov &&
@@ -168,14 +178,16 @@ test_expect_success \
test_expect_success \
'12 - unmatching local changes being removed.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo rezrov rezrov >rezrov &&
git-update-index --add rezrov &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
test_expect_success \
'13 - unmatching local changes being removed.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo rezrov rezrov >rezrov &&
git-update-index --add rezrov &&
echo rezrov >rezrov &&
@@ -188,7 +200,8 @@ EOF
test_expect_success \
'14 - unchanged in two heads.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo nitfol nitfol >nitfol &&
git-update-index --add nitfol &&
git-read-tree -m -u $treeH $treeM &&
@@ -207,7 +220,8 @@ test_expect_success \
test_expect_success \
'15 - unchanged in two heads.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo nitfol nitfol >nitfol &&
git-update-index --add nitfol &&
echo nitfol nitfol nitfol >nitfol &&
@@ -227,14 +241,16 @@ test_expect_success \
test_expect_success \
'16 - conflicting local change.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo bozbar bozbar >bozbar &&
git-update-index --add bozbar &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi'
test_expect_success \
'17 - conflicting local change.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo bozbar bozbar >bozbar &&
git-update-index --add bozbar &&
echo bozbar bozbar bozbar >bozbar &&
@@ -242,7 +258,8 @@ test_expect_success \
test_expect_success \
'18 - local change already having a good result.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo gnusto >bozbar &&
git-update-index --add bozbar &&
git-read-tree -m -u $treeH $treeM &&
@@ -254,7 +271,8 @@ test_expect_success \
test_expect_success \
'19 - local change already having a good result, further modified.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo gnusto >bozbar &&
git-update-index --add bozbar &&
echo gnusto gnusto >bozbar &&
@@ -273,7 +291,8 @@ test_expect_success \
test_expect_success \
'20 - no local change, use new tree.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo bozbar >bozbar &&
git-update-index --add bozbar &&
git-read-tree -m -u $treeH $treeM &&
@@ -285,7 +304,8 @@ test_expect_success \
test_expect_success \
'21 - no local change, dirty cache.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index nitfol bozbar rezrov frotz &&
+ git-read-tree --reset -u $treeH &&
echo bozbar >bozbar &&
git-update-index --add bozbar &&
echo gnusto gnusto >bozbar &&
@@ -294,7 +314,7 @@ test_expect_success \
# Also make sure we did not break DF vs DF/DF case.
test_expect_success \
'DF vs DF/DF case setup.' \
- 'rm -f .git/index &&
+ 'rm -f .git/index
echo DF >DF &&
git-update-index --add DF &&
treeDF=`git-write-tree` &&
diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh
index b141f89..e83bbee 100755
--- a/t/t3500-cherry.sh
+++ b/t/t3500-cherry.sh
@@ -30,6 +30,7 @@ test_expect_success \
git-commit -m "Add C." &&
git-checkout -f master &&
+ rm -f B C &&
echo Third >> A &&
git-update-index A &&
diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index 769274a..56eda63 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -191,7 +191,7 @@ test_expect_success \
'rm -fr Z [A-Z][A-Z] &&
git-read-tree $tree_A &&
git-checkout-index -f -a &&
- git-read-tree -m $tree_O || return 1
+ git-read-tree --reset $tree_O || return 1
git-update-index --refresh >/dev/null ;# this can exit non-zero
git-diff-files >.test-a &&
cmp_diff_files_output .test-a .test-recursive-OA'
@@ -201,7 +201,7 @@ test_expect_success \
'rm -fr Z [A-Z][A-Z] &&
git-read-tree $tree_B &&
git-checkout-index -f -a &&
- git-read-tree -m $tree_O || return 1
+ git-read-tree --reset $tree_O || return 1
git-update-index --refresh >/dev/null ;# this can exit non-zero
git-diff-files >.test-a &&
cmp_diff_files_output .test-a .test-recursive-OB'
@@ -211,7 +211,7 @@ test_expect_success \
'rm -fr Z [A-Z][A-Z] &&
git-read-tree $tree_B &&
git-checkout-index -f -a &&
- git-read-tree -m $tree_A || return 1
+ git-read-tree --reset $tree_A || return 1
git-update-index --refresh >/dev/null ;# this can exit non-zero
git-diff-files >.test-a &&
cmp_diff_files_output .test-a .test-recursive-AB'
diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh
index a2d24b5..5ac2564 100755
--- a/t/t6022-merge-rename.sh
+++ b/t/t6022-merge-rename.sh
@@ -111,6 +111,7 @@ test_expect_success 'pull renaming branc
test_expect_success 'pull renaming branch into another renaming one' \
'
+ rm -f B
git reset --hard
git checkout red
git pull . white && {
--
1.3.3.g8a24
^ permalink raw reply related
* Re: Git 1.3.2 on Solaris
From: Stefan Pfetzing @ 2006-05-17 8:05 UTC (permalink / raw)
To: Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0605162047380.10823@g5.osdl.org>
Hi Linus,
2006/5/17, Linus Torvalds <torvalds@osdl.org>:
>
> On Tue, 16 May 2006, Jason Riedy wrote:
> >
> > But for recommending and using git on these systems _now_...
>
> Yes. For that, I would literally suggest having people install the GNU
> tools (and/or a recent enough perl) somewhere early in the path.
>
> If you use the git wrapper, for example, you can already depend on the
> fact that it will prepend the git installation directory to the path, so
> while the GNU tools might not _normally_ be on the path, if you put them
> in the same directory as your git install, you'll automatically get them
> as long as you use the "git cmd" format (rather than the "git-cmd"
> format).
Well I guess for my pkgsrc environment this won't work.
I already (quite some time ago) tried to have gnu coreutils, findutils and
diffutils installed without the g prefix.
This broke several things on NetBSD and on Solaris.
So I'd prefer a solution where one could set one flag for the Makefile of git,
and git would check for the g prefix, create somewhere a directory with
symlinks to the "real" gnu binaries and put it into $PATH upon startup of
every git c-program or shellscript.
I suggest having these gnu "tools" dependancies removed can only be a long
term goal.
bye
dreamind
P.S.: I had to re-sent this mail, somehow gmail did put html crap into it.
--
http://www.dreamind.de/
Oroborus and Debian GNU/Linux Developer.
^ permalink raw reply
* Re: Merge with local conflicts in new files
From: Pavel Roskin @ 2006-05-17 7:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Santi, git
In-Reply-To: <7vu07p35xn.fsf@assigned-by-dhcp.cox.net>
Hello, Junio!
On Tue, 2006-05-16 at 16:28 -0700, Junio C Hamano wrote:
> Santi <sbejar@gmail.com> writes:
>
> > 2006/5/17, Junio C Hamano <junkio@cox.net>:
> >> - You have not told git that these files matter.
> >
> > For me it is the other way, all my files matter but git can do
> > whatever it wants with the ones it controls.
>
> You really do not mean that.
>
> If you told git a file matters, and have local modifications to
> the file in the working tree that you have not run update-index
> yet, merge and apply should be careful not to overwrite your
> changes that is not ready while doing whatever thing they have
> to do. And they are careful, because you have told git that
> they matter, and the way you tell git that they matter is to
> have entries for them in the index.
I'm afraid this approach, while understandable from the technical
standpoint, could prevent git from ever becoming a version control
system that "just works" without any porcelains.
I know a person who refuses to use any version control. If he
encountered this situation, he would never try any version control
again.
After all, we are talking about files in the _working_ directory. It's
not merely a transient appendix to the repository. git is not the only
player here. If a file doesn't "belong" to git, it belongs to its
"supreme commander", i.e. the user, and should be approached with utmost
care.
Merging a branch should not cause an irreparable loss of user data. The
same applies to other commands. Exceptions can be made for commands
that are specifically meant to clean user data, for commands with
special options (e.g. --force or --hard), and for the files explicitly
marked as transient (e.g. in .gitignore).
--
Regards,
Pavel Roskin
^ permalink raw reply
* Re: [PATCH] Implement git-quiltimport
From: Junio C Hamano @ 2006-05-17 5:31 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: git
In-Reply-To: <m13bf95ixo.fsf@ebiederm.dsl.xmission.com>
ebiederm@xmission.com (Eric W. Biederman) writes:
> A infrastructure question came to me when looking at this:
> several of the patches are from a branch with several authors.
> How do we specify a commit in git with several authors?
>
> There are cases when you have enough collaboration that even
> a single patch could have multiple authors, contributing equally.
The object format allows one author and one committer, but they
are only used for human consumption and log summarizing purposes
by the core. We could extend it to support more than one but I
doubt it is worth it.
I would say it would be best to place the primary contact
person, incase somebody has a problem with that particular patch
done by such a group, on the author line. Listing everybody
involved to give credits to them at the end of the log message
would also be a good idea, and that's where we usually record
attribution, sign-offs and acked-bys.
^ permalink raw reply
* Re: [PATCH] Implement git-quiltimport
From: Eric W. Biederman @ 2006-05-17 5:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Linus Torvalds, git
In-Reply-To: <7vbqtxaj5k.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
> ebiederm@xmission.com (Eric W. Biederman) writes:
>
>> Given the ugliness in -mm making it an error to have an
>> non-attributed patch would result in people specifying --author
>> when they really don't know who the author is, giving us much
>> less reliable information.
>>
>> Possibly what we need is an option to not make it an error so that
>> people doing this kind of thing in their own trees have useful
>> information.
>
> I agree it is probably a good way to error by default, optinally
> allowing to say "don't care". I do not think Linus would pull
> from such a tree or trees branched from it into his official
> tree, so I do not think we would need to worry about commits
> with incomplete information propagating for this particular
> "gitified mm" usage. But as a general purpose tool to produce
> "gitified quilt series" tree, we would.
>
> It depends on the expected use of the resulting gitified mm
> tree.
>
> If it is for an individual developer to futz with and tweak
> upon, and the end result from the work leaves such a "gitified
> quilt series" repository only as a patch form, then not having
> to figure out and specify authorship information to many patches
> is probably a plus; the information will not be part of the
> official history recorded elsewhere anyway.
So what we need for this case really is a way to mark the
commit objects in such a way that git-fetch or git-merge
would choke on the commit objects and refuse to merge.
That way the changes could not easily propagate in the wild.
Every user would at least have to specify a non-default option,
that Linus at least would never specify.
This scenario is how I have been primarily using such a tree.
> However, if it is to produce a reference git tree to point
> people at, (i.e. the quiltimport script is run once per a series
> by somebody and the result is published for public use), I would
> imagine we would want to have the attribution straight, so if
> the tool has to "guess", it should either error out or go
> interactive and ask.
Reasonable. Going interactive is probably the best way since it
appears that the patches do have sufficient information to derive
the user information from. I know people have at various times
in the past made the Andrews tree available in git form so you
could do things like git-bisect, etc. So I think we need to address
this issue. Probably by at least asking Andrew about it.
I will take a look at the policy and see what I can do. At
the very least the default we be to error on such a tree.
..
A infrastructure question came to me when looking at this:
several of the patches are from a branch with several authors.
How do we specify a commit in git with several authors?
There are cases when you have enough collaboration that even
a single patch could have multiple authors, contributing equally.
Eric
^ permalink raw reply
* Re: Git 1.3.2 on Solaris
From: Ryan Anderson @ 2006-05-17 5:15 UTC (permalink / raw)
To: Jason Riedy; +Cc: Linus Torvalds, Stefan Pfetzing, Git Mailing List
In-Reply-To: <4973.1147836384@lotus.CS.Berkeley.EDU>
On Tue, May 16, 2006 at 08:26:24PM -0700, Jason Riedy wrote:
> Plus, alas, Perl modules and Python version drift can be a bit
> of a problem on the same semi-pristine (or unmaintained, or
> too-stable) systems, so shell isn't the only thing that needs to
> go. And that'll take a good deal of effort.
The Perl used in core-git is pretty forgiving of older versions of Perl,
back to at least 5.6. (Going back to 5.005.003 is rather painful,
however, to be honest.)
The only major tool I can think of that has embedded Perl in the shell
script is format-patch. That could probably be redone in pure Perl if
it would help.
^ permalink raw reply
* Re: [PATCH] Clean up git-ls-file directory walking library interface
From: Linus Torvalds @ 2006-05-17 4:06 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0605161944480.10823@g5.osdl.org>
On Tue, 16 May 2006, Linus Torvalds wrote:
>
> That not only allows us to turn the function push_exclude_per_directory()
> static again, it also simplifies the library interface a lot (the caller
> no longer needs to worry about any of the per-directory exclude files at
> all).
Just as an example, here's all you need to basically do
git-ls-files --others --directory
--exclude-from="$GIT_DIR/info/exclude"
--exclude-per-directory=.gitignore
like "git status" does (where the "--exclude-from" is conditional on
whether the file exists or not).
Linus
---
#include "cache.h"
#include "dir.h"
int main(int argc, char **argv)
{
struct dir_struct dir;
const char *prefix = setup_git_directory();
const char *base, *path;
int baselen, i;
/* Read the index */
read_cache();
/* Set up the "struct dir_struct */
memset(&dir, 0, sizeof(dir));
dir.show_other_directories = 1;
/* normal git porcelain exclude patterns */
dir.exclude_per_dir = ".gitignore";
path = git_path("info/exclude");
if (!access(path, R_OK))
add_excludes_from_file(&dir, path);
/* Set up read_directory() arguments and go go go! */
path = ".";
base = "";
baselen = 0;
if (prefix) {
path = base = prefix;
baselen = strlen(prefix);
}
read_directory(&dir, path, base, baselen);
/* And print it all out */
if (dir.nr)
printf("#\n# Untracked files:\n#\n");
for (i = 0; i < dir.nr; i++)
printf("# %s\n", dir.entries[i]->name);
return 0;
}
^ permalink raw reply
* Re: Fwd: [OT] Re: Git via a proxy server?
From: Sam Song @ 2006-05-17 3:56 UTC (permalink / raw)
To: Petr Vandrovec; +Cc: git
In-Reply-To: <4469CF92.2010002@vmware.com>
Petr Vandrovec <petr@vmware.com> wrote:
> Best to test this is to start 'socket 192.168.40.99
> 80' from command line and
> then type these two lines above, plus one empty
> line. You should get back '200
> OK', empty line, and then you can start
> communicating using git protocol - if
> you can do that...
I cannot run "socket" and "CONNECT" on Fedora Core 3.
It simply told me that no such command. How could I
do this task in my case?
> As far as I can tell, http_proxy is ignored
> (Debian's git 1.3.2-1/cogito 0.17.2-1).
Seems you tried proxy-cmd.sh on Debian. Which
distribution did you use?
Thanks a lot,
Sam
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply
* Re: Git 1.3.2 on Solaris
From: Linus Torvalds @ 2006-05-17 3:49 UTC (permalink / raw)
To: Jason Riedy; +Cc: Stefan Pfetzing, Git Mailing List
In-Reply-To: <4973.1147836384@lotus.CS.Berkeley.EDU>
On Tue, 16 May 2006, Jason Riedy wrote:
>
> But for recommending and using git on these systems _now_...
Yes. For that, I would literally suggest having people install the GNU
tools (and/or a recent enough perl) somewhere early in the path.
If you use the git wrapper, for example, you can already depend on the
fact that it will prepend the git installation directory to the path, so
while the GNU tools might not _normally_ be on the path, if you put them
in the same directory as your git install, you'll automatically get them
as long as you use the "git cmd" format (rather than the "git-cmd"
format).
Linus
^ permalink raw reply
* Re: Git 1.3.2 on Solaris
From: Jason Riedy @ 2006-05-17 3:26 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Stefan Pfetzing, Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0605161904260.16475@g5.osdl.org>
And Linus Torvalds writes:
-
- The complete libification will take some time, and in the meantime, a few
- silly C files that hard-code the shell logic is probably much preferable
- to using the shell and all the problems that involves (like the whole
- problem with quoting arguments - just _gone_ when you do it as a execve()
- in a simple C program).
But for recommending and using git on these systems _now_...
Simply translating the shell script into C with execs doesn't
help if you're execing one of the known problems, or if the
script has embedded, non-trivial Perl. git-clone is the major
blocker; a trivial translation would be a great step but won't
let people without GNU utilities clone repos.
Plus, alas, Perl modules and Python version drift can be a bit
of a problem on the same semi-pristine (or unmaintained, or
too-stable) systems, so shell isn't the only thing that needs to
go. And that'll take a good deal of effort.
Note that my code snippets weren't a suggested patch. I wouldn't
want the easy way out to impede progress on the right thing.
But some local installations may find it much easier to patch git
than to instruct users to change their utilities to match what git
expects, especially if users have old scripts that would break
if they changed their path globally. Luckily, git makes it really
easy to keep those patches locally...
Jason
^ permalink raw reply
* [PATCH] Clean up git-ls-file directory walking library interface
From: Linus Torvalds @ 2006-05-17 2:46 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0605161859050.16475@g5.osdl.org>
This moves the code to add the per-directory ignore files for the base
directory into the library routine.
That not only allows us to turn the function push_exclude_per_directory()
static again, it also simplifies the library interface a lot (the caller
no longer needs to worry about any of the per-directory exclude files at
all).
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
dir.c | 28 +++++++++++++++++++++++++++-
dir.h | 2 --
ls-files.c | 22 +---------------------
3 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/dir.c b/dir.c
index 3f41a5d..d40b62e 100644
--- a/dir.c
+++ b/dir.c
@@ -78,7 +78,7 @@ void add_excludes_from_file(struct dir_s
die("cannot use %s as an exclude file", fname);
}
-int push_exclude_per_directory(struct dir_struct *dir, const char *base, int baselen)
+static int push_exclude_per_directory(struct dir_struct *dir, const char *base, int baselen)
{
char exclude_file[PATH_MAX];
struct exclude_list *el = &dir->exclude_list[EXC_DIRS];
@@ -289,6 +289,32 @@ static int cmp_name(const void *p1, cons
int read_directory(struct dir_struct *dir, const char *path, const char *base, int baselen)
{
+ /*
+ * Make sure to do the per-directory exclude for all the
+ * directories leading up to our base.
+ */
+ if (baselen) {
+ if (dir->exclude_per_dir) {
+ char *p, *pp = xmalloc(baselen+1);
+ memcpy(pp, base, baselen+1);
+ p = pp;
+ while (1) {
+ char save = *p;
+ *p = 0;
+ push_exclude_per_directory(dir, pp, p-pp);
+ *p++ = save;
+ if (!save)
+ break;
+ p = strchr(p, '/');
+ if (p)
+ p++;
+ else
+ p = pp + baselen;
+ }
+ free(pp);
+ }
+ }
+
read_directory_recursive(dir, path, base, baselen);
qsort(dir->entries, dir->nr, sizeof(struct dir_entry *), cmp_name);
return dir->nr;
diff --git a/dir.h b/dir.h
index e8fc441..4f65f57 100644
--- a/dir.h
+++ b/dir.h
@@ -44,7 +44,5 @@ extern int excluded(struct dir_struct *,
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
extern void add_exclude(const char *string, const char *base,
int baselen, struct exclude_list *which);
-extern int push_exclude_per_directory(struct dir_struct *,
- const char *base, int baselen);
#endif
diff --git a/ls-files.c b/ls-files.c
index 89941a3..dfe1481 100644
--- a/ls-files.c
+++ b/ls-files.c
@@ -215,28 +215,8 @@ static void show_files(struct dir_struct
const char *path = ".", *base = "";
int baselen = prefix_len;
- if (baselen) {
+ if (baselen)
path = base = prefix;
- if (dir->exclude_per_dir) {
- char *p, *pp = xmalloc(baselen+1);
- memcpy(pp, prefix, baselen+1);
- p = pp;
- while (1) {
- char save = *p;
- *p = 0;
- push_exclude_per_directory(dir, pp, p-pp);
- *p++ = save;
- if (!save)
- break;
- p = strchr(p, '/');
- if (p)
- p++;
- else
- p = pp + baselen;
- }
- free(pp);
- }
- }
read_directory(dir, path, base, baselen);
if (show_others)
show_other_files(dir);
^ permalink raw reply related
* Re: [PATCH] libify git-ls-files directory traversal
From: Linus Torvalds @ 2006-05-17 2:36 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0605161859050.16475@g5.osdl.org>
On Tue, 16 May 2006, Linus Torvalds wrote:
>
> NOTE! Not all of git-ls-files is libified by this. The index matching
> and pathspec prefix calculation is still in ls-files.c, but this is a
> big part of it.
Side note: the reason I held off on the index matching is that
git-ls-files currently uses a pretty disgusting trick to make the index
accesses faster for the common subdirectory case, namely it basically
rewrites the index so that it only contains the entries defined by a
common prefix.
Now, that's fine for git-ls-files, but it's not fine for a library
function where the caller may well want to actually use the index that it
has read in (eg "git add" and "git commit" both want to work with the
full index).
So libification of that part will require more than splitting things into
a new file and passing in a structure pointer that contains the data for
the function.
That said, a lot of the current shell scripts seem to use mainly
"git-ls-files" with the "--others" flag, and in that case the current
libification should be already sufficient.
Linus
^ permalink raw reply
* Re: Git 1.3.2 on Solaris
From: Linus Torvalds @ 2006-05-17 2:20 UTC (permalink / raw)
To: Stefan Pfetzing; +Cc: Git Mailing List
In-Reply-To: <f3d7535d0605161652n3b2ec033r874336082755e728@mail.gmail.com>
[ Junio - see the "grep" issue ]
On Wed, 17 May 2006, Stefan Pfetzing wrote:
>
> So there are 2 possible solutions to get git working on Solaris.
>
> 1. fix every single shellscript automatically during the build phase
> 2. setup a dir which contains symlinks to the "right" binaries and
> put that dir into PATH.
If the biggest issue is git depending on some GNU extensions, I'd really
suggest
(a) install all the normal GNU binaries, and put them in the path before
git just to get it working (and don't try to change git at all)
(b) help send in patches that just remove the dependency entirely.
I've been - on and off - trying to libify most of the core git sources, so
that the shell scripts can be re-written to be just plain C. Most of the
time it's not actually even a huge amount of work, it's just somewhat
boring.
Writing them as C usually gets rid of any dependencies on any GNU tools,
and hopefully even cygwin. For example, we got rid of one "xargs -0" in
the development branch pretty recently, thanks to making "git grep" a
built-in.
Of course, I don't think anybody tried the new "git grep" on Solaris, and
I think the solaris "grep" lacks the "-H" flag, for example. But that
should be easy to fix (for example, replace the use of "--" and "-H" with
putting a "/dev/null" as the first filename).
I don't think it's worth it trying to add some compatibility layer for the
shell-scripts. We really do want to get rid of them, and the more people
that help, the merrier.
In many ways, the libification effort isn't even needed. It's perfectly ok
to turn a stupid shell-script (and they really all _are_ pretty stupid)
into a builtin-cmd.c C file that just does something really easy like a
"fork + execve()" translation of the original shell script.
The complete libification will take some time, and in the meantime, a few
silly C files that hard-code the shell logic is probably much preferable
to using the shell and all the problems that involves (like the whole
problem with quoting arguments - just _gone_ when you do it as a execve()
in a simple C program).
So anybody can help with this. If you know shell (and the git
shell-scripts aren't even _advanced_ shell), and know some basic C, you're
all set to do a trivial conversion from one to the other. And when the
libification gets further, your conversion will probably help that (ie
maybe libificaiton isn't complete, but a _part_ of the thing can be
written to use the library interfaces instead of spawning an external
program).
There aren't _that_ many shell programs, and a lot of them are really
really trivial (ie they parse the arguments, and then do just a couple of
external git commands).
Linus
^ permalink raw reply
* [PATCH] libify git-ls-files directory traversal
From: Linus Torvalds @ 2006-05-17 2:02 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
This moves the core directory traversal and filename exclusion logic
into the general git library, making it available for other users
directly.
If we ever want to do "git commit" or "git add" as a built-in (and we
do), we want to be able to handle most of git-ls-files as a library.
NOTE! Not all of git-ls-files is libified by this. The index matching
and pathspec prefix calculation is still in ls-files.c, but this is a
big part of it.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
Makefile | 4 -
dir.c | 295 +++++++++++++++++++++++++++++++++++++++++++++++++
dir.h | 50 ++++++++
ls-files.c | 363 +++++-------------------------------------------------------
4 files changed, 376 insertions(+), 336 deletions(-)
diff --git a/Makefile b/Makefile
index 9ba608c..f43ac63 100644
--- a/Makefile
+++ b/Makefile
@@ -199,7 +199,7 @@ LIB_H = \
blob.h cache.h commit.h csum-file.h delta.h \
diff.h object.h pack.h pkt-line.h quote.h refs.h \
run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
- tree-walk.h log-tree.h
+ tree-walk.h log-tree.h dir.h
DIFF_OBJS = \
diff.o diff-lib.o diffcore-break.o diffcore-order.o \
@@ -210,7 +210,7 @@ LIB_OBJS = \
blob.o commit.o connect.o csum-file.o base85.o \
date.o diff-delta.o entry.o exec_cmd.o ident.o index.o \
object.o pack-check.o patch-delta.o path.o pkt-line.o \
- quote.o read-cache.o refs.o run-command.o \
+ quote.o read-cache.o refs.o run-command.o dir.o \
server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
diff --git a/dir.c b/dir.c
new file mode 100644
index 0000000..3f41a5d
--- /dev/null
+++ b/dir.c
@@ -0,0 +1,295 @@
+/*
+ * This handles recursive filename detection with exclude
+ * files, index knowledge etc..
+ *
+ * Copyright (C) Linus Torvalds, 2005-2006
+ * Junio Hamano, 2005-2006
+ */
+#include <dirent.h>
+#include <fnmatch.h>
+
+#include "cache.h"
+#include "dir.h"
+
+void add_exclude(const char *string, const char *base,
+ int baselen, struct exclude_list *which)
+{
+ struct exclude *x = xmalloc(sizeof (*x));
+
+ x->pattern = string;
+ x->base = base;
+ x->baselen = baselen;
+ if (which->nr == which->alloc) {
+ which->alloc = alloc_nr(which->alloc);
+ which->excludes = realloc(which->excludes,
+ which->alloc * sizeof(x));
+ }
+ which->excludes[which->nr++] = x;
+}
+
+static int add_excludes_from_file_1(const char *fname,
+ const char *base,
+ int baselen,
+ struct exclude_list *which)
+{
+ int fd, i;
+ long size;
+ char *buf, *entry;
+
+ fd = open(fname, O_RDONLY);
+ if (fd < 0)
+ goto err;
+ size = lseek(fd, 0, SEEK_END);
+ if (size < 0)
+ goto err;
+ lseek(fd, 0, SEEK_SET);
+ if (size == 0) {
+ close(fd);
+ return 0;
+ }
+ buf = xmalloc(size+1);
+ if (read(fd, buf, size) != size)
+ goto err;
+ close(fd);
+
+ buf[size++] = '\n';
+ entry = buf;
+ for (i = 0; i < size; i++) {
+ if (buf[i] == '\n') {
+ if (entry != buf + i && entry[0] != '#') {
+ buf[i - (i && buf[i-1] == '\r')] = 0;
+ add_exclude(entry, base, baselen, which);
+ }
+ entry = buf + i + 1;
+ }
+ }
+ return 0;
+
+ err:
+ if (0 <= fd)
+ close(fd);
+ return -1;
+}
+
+void add_excludes_from_file(struct dir_struct *dir, const char *fname)
+{
+ if (add_excludes_from_file_1(fname, "", 0,
+ &dir->exclude_list[EXC_FILE]) < 0)
+ die("cannot use %s as an exclude file", fname);
+}
+
+int push_exclude_per_directory(struct dir_struct *dir, const char *base, int baselen)
+{
+ char exclude_file[PATH_MAX];
+ struct exclude_list *el = &dir->exclude_list[EXC_DIRS];
+ int current_nr = el->nr;
+
+ if (dir->exclude_per_dir) {
+ memcpy(exclude_file, base, baselen);
+ strcpy(exclude_file + baselen, dir->exclude_per_dir);
+ add_excludes_from_file_1(exclude_file, base, baselen, el);
+ }
+ return current_nr;
+}
+
+static void pop_exclude_per_directory(struct dir_struct *dir, int stk)
+{
+ struct exclude_list *el = &dir->exclude_list[EXC_DIRS];
+
+ while (stk < el->nr)
+ free(el->excludes[--el->nr]);
+}
+
+/* Scan the list and let the last match determines the fate.
+ * Return 1 for exclude, 0 for include and -1 for undecided.
+ */
+static int excluded_1(const char *pathname,
+ int pathlen,
+ struct exclude_list *el)
+{
+ int i;
+
+ if (el->nr) {
+ for (i = el->nr - 1; 0 <= i; i--) {
+ struct exclude *x = el->excludes[i];
+ const char *exclude = x->pattern;
+ int to_exclude = 1;
+
+ if (*exclude == '!') {
+ to_exclude = 0;
+ exclude++;
+ }
+
+ if (!strchr(exclude, '/')) {
+ /* match basename */
+ const char *basename = strrchr(pathname, '/');
+ basename = (basename) ? basename+1 : pathname;
+ if (fnmatch(exclude, basename, 0) == 0)
+ return to_exclude;
+ }
+ else {
+ /* match with FNM_PATHNAME:
+ * exclude has base (baselen long) implicitly
+ * in front of it.
+ */
+ int baselen = x->baselen;
+ if (*exclude == '/')
+ exclude++;
+
+ if (pathlen < baselen ||
+ (baselen && pathname[baselen-1] != '/') ||
+ strncmp(pathname, x->base, baselen))
+ continue;
+
+ if (fnmatch(exclude, pathname+baselen,
+ FNM_PATHNAME) == 0)
+ return to_exclude;
+ }
+ }
+ }
+ return -1; /* undecided */
+}
+
+int excluded(struct dir_struct *dir, const char *pathname)
+{
+ int pathlen = strlen(pathname);
+ int st;
+
+ for (st = EXC_CMDL; st <= EXC_FILE; st++) {
+ switch (excluded_1(pathname, pathlen, &dir->exclude_list[st])) {
+ case 0:
+ return 0;
+ case 1:
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void add_name(struct dir_struct *dir, const char *pathname, int len)
+{
+ struct dir_entry *ent;
+
+ if (cache_name_pos(pathname, len) >= 0)
+ return;
+
+ if (dir->nr == dir->alloc) {
+ int alloc = alloc_nr(dir->alloc);
+ dir->alloc = alloc;
+ dir->entries = xrealloc(dir->entries, alloc*sizeof(ent));
+ }
+ ent = xmalloc(sizeof(*ent) + len + 1);
+ ent->len = len;
+ memcpy(ent->name, pathname, len);
+ ent->name[len] = 0;
+ dir->entries[dir->nr++] = ent;
+}
+
+static int dir_exists(const char *dirname, int len)
+{
+ int pos = cache_name_pos(dirname, len);
+ if (pos >= 0)
+ return 1;
+ pos = -pos-1;
+ if (pos >= active_nr) /* can't */
+ return 0;
+ return !strncmp(active_cache[pos]->name, dirname, len);
+}
+
+/*
+ * Read a directory tree. We currently ignore anything but
+ * directories, regular files and symlinks. That's because git
+ * doesn't handle them at all yet. Maybe that will change some
+ * day.
+ *
+ * Also, we ignore the name ".git" (even if it is not a directory).
+ * That likely will not change.
+ */
+static int read_directory_recursive(struct dir_struct *dir, const char *path, const char *base, int baselen)
+{
+ DIR *fdir = opendir(path);
+ int contents = 0;
+
+ if (fdir) {
+ int exclude_stk;
+ struct dirent *de;
+ char fullname[MAXPATHLEN + 1];
+ memcpy(fullname, base, baselen);
+
+ exclude_stk = push_exclude_per_directory(dir, base, baselen);
+
+ while ((de = readdir(fdir)) != NULL) {
+ int len;
+
+ if ((de->d_name[0] == '.') &&
+ (de->d_name[1] == 0 ||
+ !strcmp(de->d_name + 1, ".") ||
+ !strcmp(de->d_name + 1, "git")))
+ continue;
+ len = strlen(de->d_name);
+ memcpy(fullname + baselen, de->d_name, len+1);
+ if (excluded(dir, fullname) != dir->show_ignored) {
+ if (!dir->show_ignored || DTYPE(de) != DT_DIR) {
+ continue;
+ }
+ }
+
+ switch (DTYPE(de)) {
+ struct stat st;
+ int subdir, rewind_base;
+ default:
+ continue;
+ case DT_UNKNOWN:
+ if (lstat(fullname, &st))
+ continue;
+ if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))
+ break;
+ if (!S_ISDIR(st.st_mode))
+ continue;
+ /* fallthrough */
+ case DT_DIR:
+ memcpy(fullname + baselen + len, "/", 2);
+ len++;
+ rewind_base = dir->nr;
+ subdir = read_directory_recursive(dir, fullname, fullname,
+ baselen + len);
+ if (dir->show_other_directories &&
+ (subdir || !dir->hide_empty_directories) &&
+ !dir_exists(fullname, baselen + len)) {
+ // Rewind the read subdirectory
+ while (dir->nr > rewind_base)
+ free(dir->entries[--dir->nr]);
+ break;
+ }
+ contents += subdir;
+ continue;
+ case DT_REG:
+ case DT_LNK:
+ break;
+ }
+ add_name(dir, fullname, baselen + len);
+ contents++;
+ }
+ closedir(fdir);
+
+ pop_exclude_per_directory(dir, exclude_stk);
+ }
+
+ return contents;
+}
+
+static int cmp_name(const void *p1, const void *p2)
+{
+ const struct dir_entry *e1 = *(const struct dir_entry **)p1;
+ const struct dir_entry *e2 = *(const struct dir_entry **)p2;
+
+ return cache_name_compare(e1->name, e1->len,
+ e2->name, e2->len);
+}
+
+int read_directory(struct dir_struct *dir, const char *path, const char *base, int baselen)
+{
+ read_directory_recursive(dir, path, base, baselen);
+ qsort(dir->entries, dir->nr, sizeof(struct dir_entry *), cmp_name);
+ return dir->nr;
+}
diff --git a/dir.h b/dir.h
new file mode 100644
index 0000000..e8fc441
--- /dev/null
+++ b/dir.h
@@ -0,0 +1,50 @@
+#ifndef DIR_H
+#define DIR_H
+
+/*
+ * We maintain three exclude pattern lists:
+ * EXC_CMDL lists patterns explicitly given on the command line.
+ * EXC_DIRS lists patterns obtained from per-directory ignore files.
+ * EXC_FILE lists patterns from fallback ignore files.
+ */
+#define EXC_CMDL 0
+#define EXC_DIRS 1
+#define EXC_FILE 2
+
+
+struct dir_entry {
+ int len;
+ char name[FLEX_ARRAY]; /* more */
+};
+
+struct exclude_list {
+ int nr;
+ int alloc;
+ struct exclude {
+ const char *pattern;
+ const char *base;
+ int baselen;
+ } **excludes;
+};
+
+struct dir_struct {
+ int nr, alloc;
+ unsigned int show_ignored:1,
+ show_other_directories:1,
+ hide_empty_directories:1;
+ struct dir_entry **entries;
+
+ /* Exclude info */
+ const char *exclude_per_dir;
+ struct exclude_list exclude_list[3];
+};
+
+extern int read_directory(struct dir_struct *, const char *path, const char *base, int baselen);
+extern int excluded(struct dir_struct *, const char *);
+extern void add_excludes_from_file(struct dir_struct *, const char *fname);
+extern void add_exclude(const char *string, const char *base,
+ int baselen, struct exclude_list *which);
+extern int push_exclude_per_directory(struct dir_struct *,
+ const char *base, int baselen);
+
+#endif
diff --git a/ls-files.c b/ls-files.c
index 4a4af1c..89941a3 100644
--- a/ls-files.c
+++ b/ls-files.c
@@ -5,23 +5,20 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
-#include <dirent.h>
#include <fnmatch.h>
#include "cache.h"
#include "quote.h"
+#include "dir.h"
static int abbrev = 0;
static int show_deleted = 0;
static int show_cached = 0;
static int show_others = 0;
-static int show_ignored = 0;
static int show_stage = 0;
static int show_unmerged = 0;
static int show_modified = 0;
static int show_killed = 0;
-static int show_other_directories = 0;
-static int hide_empty_directories = 0;
static int show_valid_bit = 0;
static int line_terminator = '\n';
@@ -38,309 +35,6 @@ static const char *tag_other = "";
static const char *tag_killed = "";
static const char *tag_modified = "";
-static const char *exclude_per_dir = NULL;
-
-/* We maintain three exclude pattern lists:
- * EXC_CMDL lists patterns explicitly given on the command line.
- * EXC_DIRS lists patterns obtained from per-directory ignore files.
- * EXC_FILE lists patterns from fallback ignore files.
- */
-#define EXC_CMDL 0
-#define EXC_DIRS 1
-#define EXC_FILE 2
-static struct exclude_list {
- int nr;
- int alloc;
- struct exclude {
- const char *pattern;
- const char *base;
- int baselen;
- } **excludes;
-} exclude_list[3];
-
-static void add_exclude(const char *string, const char *base,
- int baselen, struct exclude_list *which)
-{
- struct exclude *x = xmalloc(sizeof (*x));
-
- x->pattern = string;
- x->base = base;
- x->baselen = baselen;
- if (which->nr == which->alloc) {
- which->alloc = alloc_nr(which->alloc);
- which->excludes = realloc(which->excludes,
- which->alloc * sizeof(x));
- }
- which->excludes[which->nr++] = x;
-}
-
-static int add_excludes_from_file_1(const char *fname,
- const char *base,
- int baselen,
- struct exclude_list *which)
-{
- int fd, i;
- long size;
- char *buf, *entry;
-
- fd = open(fname, O_RDONLY);
- if (fd < 0)
- goto err;
- size = lseek(fd, 0, SEEK_END);
- if (size < 0)
- goto err;
- lseek(fd, 0, SEEK_SET);
- if (size == 0) {
- close(fd);
- return 0;
- }
- buf = xmalloc(size+1);
- if (read(fd, buf, size) != size)
- goto err;
- close(fd);
-
- buf[size++] = '\n';
- entry = buf;
- for (i = 0; i < size; i++) {
- if (buf[i] == '\n') {
- if (entry != buf + i && entry[0] != '#') {
- buf[i - (i && buf[i-1] == '\r')] = 0;
- add_exclude(entry, base, baselen, which);
- }
- entry = buf + i + 1;
- }
- }
- return 0;
-
- err:
- if (0 <= fd)
- close(fd);
- return -1;
-}
-
-static void add_excludes_from_file(const char *fname)
-{
- if (add_excludes_from_file_1(fname, "", 0,
- &exclude_list[EXC_FILE]) < 0)
- die("cannot use %s as an exclude file", fname);
-}
-
-static int push_exclude_per_directory(const char *base, int baselen)
-{
- char exclude_file[PATH_MAX];
- struct exclude_list *el = &exclude_list[EXC_DIRS];
- int current_nr = el->nr;
-
- if (exclude_per_dir) {
- memcpy(exclude_file, base, baselen);
- strcpy(exclude_file + baselen, exclude_per_dir);
- add_excludes_from_file_1(exclude_file, base, baselen, el);
- }
- return current_nr;
-}
-
-static void pop_exclude_per_directory(int stk)
-{
- struct exclude_list *el = &exclude_list[EXC_DIRS];
-
- while (stk < el->nr)
- free(el->excludes[--el->nr]);
-}
-
-/* Scan the list and let the last match determines the fate.
- * Return 1 for exclude, 0 for include and -1 for undecided.
- */
-static int excluded_1(const char *pathname,
- int pathlen,
- struct exclude_list *el)
-{
- int i;
-
- if (el->nr) {
- for (i = el->nr - 1; 0 <= i; i--) {
- struct exclude *x = el->excludes[i];
- const char *exclude = x->pattern;
- int to_exclude = 1;
-
- if (*exclude == '!') {
- to_exclude = 0;
- exclude++;
- }
-
- if (!strchr(exclude, '/')) {
- /* match basename */
- const char *basename = strrchr(pathname, '/');
- basename = (basename) ? basename+1 : pathname;
- if (fnmatch(exclude, basename, 0) == 0)
- return to_exclude;
- }
- else {
- /* match with FNM_PATHNAME:
- * exclude has base (baselen long) implicitly
- * in front of it.
- */
- int baselen = x->baselen;
- if (*exclude == '/')
- exclude++;
-
- if (pathlen < baselen ||
- (baselen && pathname[baselen-1] != '/') ||
- strncmp(pathname, x->base, baselen))
- continue;
-
- if (fnmatch(exclude, pathname+baselen,
- FNM_PATHNAME) == 0)
- return to_exclude;
- }
- }
- }
- return -1; /* undecided */
-}
-
-static int excluded(const char *pathname)
-{
- int pathlen = strlen(pathname);
- int st;
-
- for (st = EXC_CMDL; st <= EXC_FILE; st++) {
- switch (excluded_1(pathname, pathlen, &exclude_list[st])) {
- case 0:
- return 0;
- case 1:
- return 1;
- }
- }
- return 0;
-}
-
-struct nond_on_fs {
- int len;
- char name[FLEX_ARRAY]; /* more */
-};
-
-static struct nond_on_fs **dir;
-static int nr_dir;
-static int dir_alloc;
-
-static void add_name(const char *pathname, int len)
-{
- struct nond_on_fs *ent;
-
- if (cache_name_pos(pathname, len) >= 0)
- return;
-
- if (nr_dir == dir_alloc) {
- dir_alloc = alloc_nr(dir_alloc);
- dir = xrealloc(dir, dir_alloc*sizeof(ent));
- }
- ent = xmalloc(sizeof(*ent) + len + 1);
- ent->len = len;
- memcpy(ent->name, pathname, len);
- ent->name[len] = 0;
- dir[nr_dir++] = ent;
-}
-
-static int dir_exists(const char *dirname, int len)
-{
- int pos = cache_name_pos(dirname, len);
- if (pos >= 0)
- return 1;
- pos = -pos-1;
- if (pos >= active_nr) /* can't */
- return 0;
- return !strncmp(active_cache[pos]->name, dirname, len);
-}
-
-/*
- * Read a directory tree. We currently ignore anything but
- * directories, regular files and symlinks. That's because git
- * doesn't handle them at all yet. Maybe that will change some
- * day.
- *
- * Also, we ignore the name ".git" (even if it is not a directory).
- * That likely will not change.
- */
-static int read_directory(const char *path, const char *base, int baselen)
-{
- DIR *fdir = opendir(path);
- int contents = 0;
-
- if (fdir) {
- int exclude_stk;
- struct dirent *de;
- char fullname[MAXPATHLEN + 1];
- memcpy(fullname, base, baselen);
-
- exclude_stk = push_exclude_per_directory(base, baselen);
-
- while ((de = readdir(fdir)) != NULL) {
- int len;
-
- if ((de->d_name[0] == '.') &&
- (de->d_name[1] == 0 ||
- !strcmp(de->d_name + 1, ".") ||
- !strcmp(de->d_name + 1, "git")))
- continue;
- len = strlen(de->d_name);
- memcpy(fullname + baselen, de->d_name, len+1);
- if (excluded(fullname) != show_ignored) {
- if (!show_ignored || DTYPE(de) != DT_DIR) {
- continue;
- }
- }
-
- switch (DTYPE(de)) {
- struct stat st;
- int subdir, rewind_base;
- default:
- continue;
- case DT_UNKNOWN:
- if (lstat(fullname, &st))
- continue;
- if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))
- break;
- if (!S_ISDIR(st.st_mode))
- continue;
- /* fallthrough */
- case DT_DIR:
- memcpy(fullname + baselen + len, "/", 2);
- len++;
- rewind_base = nr_dir;
- subdir = read_directory(fullname, fullname,
- baselen + len);
- if (show_other_directories &&
- (subdir || !hide_empty_directories) &&
- !dir_exists(fullname, baselen + len)) {
- // Rewind the read subdirectory
- while (nr_dir > rewind_base)
- free(dir[--nr_dir]);
- break;
- }
- contents += subdir;
- continue;
- case DT_REG:
- case DT_LNK:
- break;
- }
- add_name(fullname, baselen + len);
- contents++;
- }
- closedir(fdir);
-
- pop_exclude_per_directory(exclude_stk);
- }
-
- return contents;
-}
-
-static int cmp_name(const void *p1, const void *p2)
-{
- const struct nond_on_fs *e1 = *(const struct nond_on_fs **)p1;
- const struct nond_on_fs *e2 = *(const struct nond_on_fs **)p2;
-
- return cache_name_compare(e1->name, e1->len,
- e2->name, e2->len);
-}
/*
* Match a pathspec against a filename. The first "len" characters
@@ -377,7 +71,7 @@ static int match(const char **spec, char
return 0;
}
-static void show_dir_entry(const char *tag, struct nond_on_fs *ent)
+static void show_dir_entry(const char *tag, struct dir_entry *ent)
{
int len = prefix_len;
int offset = prefix_offset;
@@ -393,14 +87,14 @@ static void show_dir_entry(const char *t
putchar(line_terminator);
}
-static void show_other_files(void)
+static void show_other_files(struct dir_struct *dir)
{
int i;
- for (i = 0; i < nr_dir; i++) {
+ for (i = 0; i < dir->nr; i++) {
/* We should not have a matching entry, but we
* may have an unmerged entry for this path.
*/
- struct nond_on_fs *ent = dir[i];
+ struct dir_entry *ent = dir->entries[i];
int pos = cache_name_pos(ent->name, ent->len);
struct cache_entry *ce;
if (0 <= pos)
@@ -416,11 +110,11 @@ static void show_other_files(void)
}
}
-static void show_killed_files(void)
+static void show_killed_files(struct dir_struct *dir)
{
int i;
- for (i = 0; i < nr_dir; i++) {
- struct nond_on_fs *ent = dir[i];
+ for (i = 0; i < dir->nr; i++) {
+ struct dir_entry *ent = dir->entries[i];
char *cp, *sp;
int pos, len, killed = 0;
@@ -461,7 +155,7 @@ static void show_killed_files(void)
}
}
if (killed)
- show_dir_entry(tag_killed, dir[i]);
+ show_dir_entry(tag_killed, dir->entries[i]);
}
}
@@ -512,7 +206,7 @@ static void show_ce_entry(const char *ta
}
}
-static void show_files(void)
+static void show_files(struct dir_struct *dir)
{
int i;
@@ -523,14 +217,14 @@ static void show_files(void)
if (baselen) {
path = base = prefix;
- if (exclude_per_dir) {
+ if (dir->exclude_per_dir) {
char *p, *pp = xmalloc(baselen+1);
memcpy(pp, prefix, baselen+1);
p = pp;
while (1) {
char save = *p;
*p = 0;
- push_exclude_per_directory(pp, p-pp);
+ push_exclude_per_directory(dir, pp, p-pp);
*p++ = save;
if (!save)
break;
@@ -543,17 +237,16 @@ static void show_files(void)
free(pp);
}
}
- read_directory(path, base, baselen);
- qsort(dir, nr_dir, sizeof(struct nond_on_fs *), cmp_name);
+ read_directory(dir, path, base, baselen);
if (show_others)
- show_other_files();
+ show_other_files(dir);
if (show_killed)
- show_killed_files();
+ show_killed_files(dir);
}
if (show_cached | show_stage) {
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
- if (excluded(ce->name) != show_ignored)
+ if (excluded(dir, ce->name) != dir->show_ignored)
continue;
if (show_unmerged && !ce_stage(ce))
continue;
@@ -565,7 +258,7 @@ static void show_files(void)
struct cache_entry *ce = active_cache[i];
struct stat st;
int err;
- if (excluded(ce->name) != show_ignored)
+ if (excluded(dir, ce->name) != dir->show_ignored)
continue;
err = lstat(ce->name, &st);
if (show_deleted && err)
@@ -652,7 +345,9 @@ int main(int argc, const char **argv)
{
int i;
int exc_given = 0;
+ struct dir_struct dir;
+ memset(&dir, 0, sizeof(dir));
prefix = setup_git_directory();
if (prefix)
prefix_offset = strlen(prefix);
@@ -697,7 +392,7 @@ int main(int argc, const char **argv)
continue;
}
if (!strcmp(arg, "-i") || !strcmp(arg, "--ignored")) {
- show_ignored = 1;
+ dir.show_ignored = 1;
continue;
}
if (!strcmp(arg, "-s") || !strcmp(arg, "--stage")) {
@@ -709,11 +404,11 @@ int main(int argc, const char **argv)
continue;
}
if (!strcmp(arg, "--directory")) {
- show_other_directories = 1;
+ dir.show_other_directories = 1;
continue;
}
if (!strcmp(arg, "--no-empty-directory")) {
- hide_empty_directories = 1;
+ dir.hide_empty_directories = 1;
continue;
}
if (!strcmp(arg, "-u") || !strcmp(arg, "--unmerged")) {
@@ -726,27 +421,27 @@ int main(int argc, const char **argv)
}
if (!strcmp(arg, "-x") && i+1 < argc) {
exc_given = 1;
- add_exclude(argv[++i], "", 0, &exclude_list[EXC_CMDL]);
+ add_exclude(argv[++i], "", 0, &dir.exclude_list[EXC_CMDL]);
continue;
}
if (!strncmp(arg, "--exclude=", 10)) {
exc_given = 1;
- add_exclude(arg+10, "", 0, &exclude_list[EXC_CMDL]);
+ add_exclude(arg+10, "", 0, &dir.exclude_list[EXC_CMDL]);
continue;
}
if (!strcmp(arg, "-X") && i+1 < argc) {
exc_given = 1;
- add_excludes_from_file(argv[++i]);
+ add_excludes_from_file(&dir, argv[++i]);
continue;
}
if (!strncmp(arg, "--exclude-from=", 15)) {
exc_given = 1;
- add_excludes_from_file(arg+15);
+ add_excludes_from_file(&dir, arg+15);
continue;
}
if (!strncmp(arg, "--exclude-per-directory=", 24)) {
exc_given = 1;
- exclude_per_dir = arg + 24;
+ dir.exclude_per_dir = arg + 24;
continue;
}
if (!strcmp(arg, "--full-name")) {
@@ -788,7 +483,7 @@ int main(int argc, const char **argv)
ps_matched = xcalloc(1, num);
}
- if (show_ignored && !exc_given) {
+ if (dir.show_ignored && !exc_given) {
fprintf(stderr, "%s: --ignored needs some exclude pattern\n",
argv[0]);
exit(1);
@@ -802,7 +497,7 @@ int main(int argc, const char **argv)
read_cache();
if (prefix)
prune_cache();
- show_files();
+ show_files(&dir);
if (ps_matched) {
/* We need to make sure all pathspec matched otherwise
^ permalink raw reply related
* Re: Git 1.3.2 on Solaris
From: Jason Riedy @ 2006-05-17 1:25 UTC (permalink / raw)
To: Stefan Pfetzing; +Cc: git
In-Reply-To: <f3d7535d0605161652n3b2ec033r874336082755e728@mail.gmail.com>
And "Stefan Pfetzing" writes:
- I've been trying to get git to work on the latest Solaris Express
- release (with the help of NetBSD's pkgsrc).
I've been using it on Solaris 8 and 9 with the GNU tools
in pkgsrc for quite a while, as well as on AIX with the
GNU tools available as modules (but I haven't compiled a
new AIX version for a month or two).
- It mostly miserabely fails because of common "shell commands" being
- used with GNU options. (like xargs, diff, tr and prob. some more) On
- my box (and thats AFAIK the default when you install gnu coreutils on
- Solaris) the commands do have a g prefix.
In your pkgsrc mk.conf, use:
GNU_PROGRAM_PREFIX=
GTAR_PROGRAM_PREFIX=
I tried your first suggestion (patch all the commands) back
in February. It's pretty fragile against future changes, and
I wouldn't recommend it.
- 2. setup a dir which contains symlinks to the "right" binaries and
- put that dir into PATH.
Setting a GIT_COMPAT_PATH in the Makefile and prepending
it to the path in git.c and git-sh-setup.sh might be more
sane. A fragment like the following in git.c before adding
GIT_EXEC_PATH:
#ifdef GIT_COMPAT_PATH
/* Search for sane external utilities */
prepend_to_path(GIT_COMPAT_PATH, strlen(GIT_COMPAT_PATH));
#endif
And maybe in git-sh-setup.sh to help those of us who
use git-foo rather than git foo:
if [ ! -z "@GIT_COMPAT_PATH@" ] ; then
PATH="@GIT_COMPAT_PATH@:${PATH}"
export PATH
fi
Plus Makefile fun.
Jason
^ permalink raw reply
* Git 1.3.2 on Solaris
From: Stefan Pfetzing @ 2006-05-16 23:52 UTC (permalink / raw)
To: git
Hi,
I've been trying to get git to work on the latest Solaris Express
release (with the help of NetBSD's pkgsrc).
It mostly miserabely fails because of common "shell commands" being
used with GNU options. (like xargs, diff, tr and prob. some more) On
my box (and thats AFAIK the default when you install gnu coreutils on
Solaris) the commands do have a g prefix.
So there are 2 possible solutions to get git working on Solaris.
1. fix every single shellscript automatically during the build phase
2. setup a dir which contains symlinks to the "right" binaries and
put that dir into PATH.
No matter what solution is chosen to be the best, I'm volunteering to
create a patch for it. :)
(although I personally prefer the second, because its easier...)
bye
Stefan
--
http://www.dreamind.de/
Oroborus and Debian GNU/Linux Developer.
^ permalink raw reply
* Remove old "git-grep.sh" remnants
From: Linus Torvalds @ 2006-05-16 23:46 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
It's built-in now.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
----
diff --git a/Makefile b/Makefile
index 93779b0..9ba608c 100644
--- a/Makefile
+++ b/Makefile
@@ -124,7 +124,7 @@ SCRIPT_SH = \
git-tag.sh git-verify-tag.sh \
git-applymbox.sh git-applypatch.sh git-am.sh \
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
- git-merge-resolve.sh git-merge-ours.sh git-grep.sh \
+ git-merge-resolve.sh git-merge-ours.sh \
git-lost-found.sh
SCRIPT_PERL = \
@@ -169,7 +169,8 @@ PROGRAMS = \
git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
BUILT_INS = git-log$X git-whatchanged$X git-show$X \
- git-count-objects$X git-diff$X git-push$X
+ git-count-objects$X git-diff$X git-push$X \
+ git-grep$X
# what 'all' will build and 'install' will install, in gitexecdir
ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
diff --git a/git-grep.sh b/git-grep.sh
deleted file mode 100755
index ad4f2fe..0000000
--- a/git-grep.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) Linus Torvalds, 2005
-#
-
-USAGE='[<option>...] [-e] <pattern> [<path>...]'
-SUBDIRECTORY_OK='Yes'
-. git-sh-setup
-
-got_pattern () {
- if [ -z "$no_more_patterns" ]
- then
- pattern="$1" no_more_patterns=yes
- else
- die "git-grep: do not specify more than one pattern"
- fi
-}
-
-no_more_patterns=
-pattern=
-flags=()
-git_flags=()
-while : ; do
- case "$1" in
- -o|--cached|--deleted|--others|--killed|\
- --ignored|--modified|--exclude=*|\
- --exclude-from=*|\--exclude-per-directory=*)
- git_flags=("${git_flags[@]}" "$1")
- ;;
- -e)
- got_pattern "$2"
- shift
- ;;
- -A|-B|-C|-D|-d|-f|-m)
- flags=("${flags[@]}" "$1" "$2")
- shift
- ;;
- --)
- # The rest are git-ls-files paths
- shift
- break
- ;;
- -*)
- flags=("${flags[@]}" "$1")
- ;;
- *)
- if [ -z "$no_more_patterns" ]
- then
- got_pattern "$1"
- shift
- fi
- [ "$1" = -- ] && shift
- break
- ;;
- esac
- shift
-done
-[ "$pattern" ] || {
- usage
-}
-git-ls-files -z "${git_flags[@]}" -- "$@" |
- xargs -0 grep "${flags[@]}" -e "$pattern" --
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox