* 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
* 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
* [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: 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
* 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: 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: [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: 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] 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: [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: 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: 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
* [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: 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
* 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: [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: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: 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: 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: 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: 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:22 UTC (permalink / raw)
To: Stefan Pfetzing; +Cc: git
In-Reply-To: <f3d7535d0605170206y76e24f25w305a688d32f4a0a1@mail.gmail.com>
"Stefan Pfetzing" <stefan.pfetzing@gmail.com> writes:
> 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.
If you look at our Makefile, you will see bindir does not have
to be gitexecdir. The suggestion by Linus is that you set
bindir to /usr/local/bin or whereever your distribution's
packaging scheme wants the locally installed software to be that
is on user's PATH, and gitexecdir to /usr/local/libexec/git
(again, whereever), _and_ have:
ln -s /usr/bin/gtr /usr/local/libexec/git/tr
ln -s /usr/bin/gxargs /usr/local/libexec/git/xargs
...
Then:
(1) git and gitk are available in /usr/local/bin;
(2) while git and gitk runs, /usr/local/libexec/git will
be prepended to the PATH, so when they want xargs,
they will get gxargs;
(3) but your users will _not_ have /usr/local/libexec/git
on their PATH, so when they type xargs they will get
the one that barfs on -0 option.
and train your users and user's scripts to use the officially
sanctioned way to refer to git subprograms. From interactive
sessions, say "git foo", not "git-foo". If your script _really_
cares about extra exec git wrapper does, use "git --exec-path"
upfront in the script to obtain correct gitexecpath, export
GIT_EXEC_PATH environment variable with that value, and prepend
it to PATH so that it can find "git-foo" executable (you would
probably need to do both, so that git-foo can find git-bar and
its friends).
^ permalink raw reply
* git-add + git-reset --hard = Arrrggh!
From: Shawn Pearce @ 2006-05-17 9:45 UTC (permalink / raw)
To: git
After spending an hour writing and testing a new test case for GIT
I do the foolish:
$ git add t/t1400-update-ref.sh
# Hmm, maybe I should amend this into the prior commit.
$ git format-patch -o .. next
$ git reset --hard
$ git update-ref HEAD~1
# Uhhohh...
$ ls t/t1400-update-ref.sh
All I can say is I'm very happy that update-index does a lot more
than just update the index. I was easily able to find the deleted
test by finding the most recently modified object in my .git/objects
directory and pulling it back out with git cat-file. :-)
Oh, and I totally agree with that discussion about GIT not clobbering
files the user is working on which the user can't easily recover.
I just wish recovery from the above stupidity didn't require going
through .git/objects looking for the newest file. :-)
Yes, I know that git reset --hard was brutal and yes, I didn't
really need to use git-update-ref when git-reset would have also
done the job for me. Arrgh. Its early and I wasn't thinking.
--
Shawn.
^ permalink raw reply
* [RFC 0/5] Log history of a ref
From: Shawn Pearce @ 2006-05-17 9:54 UTC (permalink / raw)
To: git
The following 5 [RFC] patches from me are all related to logging
changes made to a ref. These patches contain the same basic idea
as the two patches I floated earlier this week. Log files reside
in .git/logs<ref> and logging is enabled either by creating the
log file or by setting 'core.logAllRefUpdates' to true.
Summary is:
* [RFC 1/5] Remove unnecessary local in get_ref_sha1.
A minor code cleanup.
* [RFC 2/5] Improve abstraction of ref lock/write.
A major reorg of the write_ref_sha1 APIs. This reorg allows
all internal code to use the same logic for updating any ref,
which makes it much easier to hook logging in.
* [RFC 3/5] Convert update-ref to use ref_lock API.
Modify update-ref to use the reorg'd write_ref_sha1 API.
* [RFC 4/5] Log ref updates to logs/refs/<ref>
Add logging of refs. This is the pretty much my latest
logging patch but cleaned up and built on the above.
* [RFC 5/5] Support 'master@2 hours ago' syntax
Extend the SHA1 syntax to search the log for the SHA1 which
was valid at the given point in time.
I still need to fix the receive-pack code to log ref changes prior
to running the update hook. I'll probably look at that later this
week. I also need to edit the ~20 sites which call 'git-update-ref'
to make use of the new "-m <reason>" flag.
--
Shawn.
^ permalink raw reply
* [PATCH] builtin-grep: workaround for non GNU grep.
From: Junio C Hamano @ 2006-05-17 9:54 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vejythvkr.fsf@assigned-by-dhcp.cox.net>
Some implementations do not know what to do with -H; define
NO_H_OPTION_IN_GREP when you build git if your grep lacks -H.
Most of the time, it can be worked around by prepending
/dev/null to the argument list, but that causes -L and -c to
slightly misbehave (they both expose /dev/null is given), so
when these options are given, do not run external grep that does
not understand -H.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Junio C Hamano <junkio@cox.net> writes:
> 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.
So this is an updated version. I am not proud of the handling
of the new Makefile variable, although I like the C code that
does not need #ifdef thanks to it.
Makefile | 11 +++++++++++
builtin-grep.c | 22 +++++++++++++++++++---
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 9ba608c..c67108d 100644
--- a/Makefile
+++ b/Makefile
@@ -46,6 +46,8 @@ # Patrick Mauritz).
#
# Define NO_MMAP if you want to avoid mmap.
#
+# Define NO_H_OPTION_IN_GREP if your grep does not understand -H.
+#
# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
#
# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
@@ -444,6 +446,12 @@ ifdef NO_ACCURATE_DIFF
ALL_CFLAGS += -DNO_ACCURATE_DIFF
endif
+ifdef NO_H_OPTION_IN_GREP
+ NO_H_OPTION_IN_GREP=1
+else
+ NO_H_OPTION_IN_GREP=0
+endif
+
# Shell quote (do not use $(call) to accomodate ancient setups);
SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
@@ -526,6 +534,9 @@ git$X git.spec \
%.o: %.S
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
+builtin-grep.o: builtin-grep.c
+ $(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_H_OPTION_IN_GREP=$(NO_H_OPTION_IN_GREP) $<
+
exec_cmd.o: exec_cmd.c
$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
diff --git a/builtin-grep.c b/builtin-grep.c
index 66111de..36512d8 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,13 @@ static int external_grep(struct grep_opt
push_arg("-e");
push_arg(p->pattern);
}
- push_arg("--");
+
+ if (NO_H_OPTION_IN_GREP)
+ push_arg("/dev/null");
+ else {
+ push_arg("-H");
+ push_arg("--");
+ }
hit = 0;
argc = nr;
@@ -535,8 +540,19 @@ #ifdef __unix__
* Use the external "grep" command for the case where
* we grep through the checked-out files. It tends to
* be a lot more optimized
+ *
+ * Some grep implementations do not understand -H nor --
+ * but /dev/null can be used as a substitution in most
+ * cases.
+ *
+ * However -L and -c would slightly misbehave (-L would
+ * list /dev/null as a hit, and -c would report 0 hits
+ * from /dev/null); so do not use the external one on
+ * such platforms.
*/
- if (!cached) {
+ if (!cached &&
+ (!NO_H_OPTION_IN_GREP ||
+ (!opt->count && !opt->unmatch_name_only))) {
hit = external_grep(opt, paths, cached);
if (hit >= 0)
return hit;
--
1.3.3.g8a24
^ 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