Git development
 help / color / mirror / Atom feed
* [StGit PATCH 2/2] Test the new stg delete --spill flag
From: Karl Hasselström @ 2008-09-21 19:07 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20080921190708.4503.20574.stgit@yoghurt>

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 t/t1602-delete-spill.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)
 create mode 100755 t/t1602-delete-spill.sh


diff --git a/t/t1602-delete-spill.sh b/t/t1602-delete-spill.sh
new file mode 100755
index 0000000..1ddec53
--- /dev/null
+++ b/t/t1602-delete-spill.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+test_description='Test "stg delete --spill"'
+. ./test-lib.sh
+
+test_expect_success 'Initialize the StGIT repository' '
+    stg init
+'
+
+test_expect_success 'Create five applied and three unapplied patches' '
+    for i in 0 1 2 3 4 5 6 7; do
+        echo $i >> foo &&
+        git add foo &&
+        git commit -m p$i
+    done
+    stg uncommit -n 8 &&
+    stg pop -n 3
+'
+
+test_expect_success 'Try to delete --spill an unapplied patch' '
+    command_error stg delete --spill p7 &&
+    test "$(echo $(stg series))" = "+ p0 + p1 + p2 + p3 > p4 - p5 - p6 - p7" &&
+    test "$(echo $(cat foo))" = "0 1 2 3 4" &&
+    test "$(echo $(git diff-files))" = ""
+'
+
+test_expect_success 'Try to delete --spill a non-top patch' '
+    command_error stg delete --spill p2 &&
+    test "$(echo $(stg series))" = "+ p0 + p1 + p2 + p3 > p4 - p5 - p6 - p7" &&
+    test "$(echo $(cat foo))" = "0 1 2 3 4" &&
+    test "$(echo $(git diff-files))" = ""
+'
+
+test_expect_success 'Delete --spill one patch' '
+    stg delete --spill p4 &&
+    test "$(echo $(stg series))" = "+ p0 + p1 + p2 > p3 - p5 - p6 - p7" &&
+    test "$(echo $(cat foo))" = "0 1 2 3 4" &&
+    test "$(echo $(git diff-files))" = ""
+'
+
+test_expect_success 'Delete --spill several patches' '
+    stg delete --spill p2 p3 p1 &&
+    test "$(echo $(stg series))" = "> p0 - p5 - p6 - p7" &&
+    test "$(echo $(cat foo))" = "0 1 2 3 4" &&
+    test "$(echo $(git diff-files))" = ""
+'
+
+test_done

^ permalink raw reply related

* [StGit PATCH 1/2] Add a new flag, --spill, to stg delete
From: Karl Hasselström @ 2008-09-21 19:07 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20080921190708.4503.20574.stgit@yoghurt>

It deletes the patches as usual, but doesn't touch index+worktree.
Useful for splitting up a patch, or undoing an "stg refresh".

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/delete.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)


diff --git a/stgit/commands/delete.py b/stgit/commands/delete.py
index 1b59cdd..015fb49 100644
--- a/stgit/commands/delete.py
+++ b/stgit/commands/delete.py
@@ -30,6 +30,13 @@ Delete the patches passed as arguments."""
 args = [argparse.patch_range(argparse.applied_patches,
                              argparse.unapplied_patches)]
 options = [
+    opt('--spill', action = 'store_true',
+        short = 'Spill patch contents to worktree and index', long = """
+        Delete the patches, but do not touch the index and worktree.
+        This only works with applied patches at the top of the stack.
+        The effect is to "spill" the patch contents into the index and
+        worktree. This can be useful e.g. if you want to split a patch
+        into several smaller pieces."""),
     opt('-b', '--branch', args = [argparse.stg_branches],
         short = 'Use BRANCH instead of the default branch')]
 
@@ -46,6 +53,12 @@ def func(parser, options, args):
         patches = set(common.parse_patches(args, list(stack.patchorder.all)))
     else:
         parser.error('No patches specified')
+
+    if options.spill:
+        if set(stack.patchorder.applied[-len(patches):]) != patches:
+            parser.error('Can only spill topmost applied patches')
+        iw = None # don't touch index+worktree
+
     def allow_conflicts(trans):
         # Allow conflicts if the topmost patch stays the same.
         if stack.patchorder.applied:

^ permalink raw reply related

* [StGit PATCH 0/2] stg delete --spill
From: Karl Hasselström @ 2008-09-21 19:07 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

---

Karl Hasselström (2):
      Test the new stg delete --spill flag
      Add a new flag, --spill, to stg delete


 stgit/commands/delete.py |   13 +++++++++++++
 t/t1602-delete-spill.sh  |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 0 deletions(-)
 create mode 100755 t/t1602-delete-spill.sh

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply

* Re: Git-1.6.0.2-preview20080921 on Windows
From: Jakub Narebski @ 2008-09-21 19:07 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: msysGit, Git Mailing List
In-Reply-To: <82166911-C34F-439C-A2F3-CEBD7346A1D6@zib.de>


Steffen Prohaska <prohaska@zib.de> writes:

> Git-1.6.0.2-preview20080921 for Windows is available at
> 
>      http://code.google.com/p/msysgit/downloads

Wouldn't it be better if this email had [ANNOUNCE] in the subject, to
be catched by mail2rss thingy that feeds Ohloh page for Git?

-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply

* [StGit PATCH] Remove misleading "stg delete" documentation
From: Karl Hasselström @ 2008-09-21 19:06 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

With the recent arrival of the stack log, patch
deletion can now be undone.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/commands/delete.py |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)


diff --git a/stgit/commands/delete.py b/stgit/commands/delete.py
index 40cef3f..1b59cdd 100644
--- a/stgit/commands/delete.py
+++ b/stgit/commands/delete.py
@@ -25,9 +25,7 @@ help = 'Delete patches'
 kind = 'patch'
 usage = ['[options] <patch1> [<patch2>] [<patch3>..<patch4>]']
 description = """
-Delete the patches passed as arguments.
-
-Note that the 'delete' operation is irreversible."""
+Delete the patches passed as arguments."""
 
 args = [argparse.patch_range(argparse.applied_patches,
                              argparse.unapplied_patches)]

^ permalink raw reply related

* Re: [PATCH (GIT-GUI,GITK) 6/8] gitk: Port new encoding logic from git-gui.
From: Alexander Gavrilov @ 2008-09-21 18:52 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Shawn O. Pearce, Paul Mackerras
In-Reply-To: <48D3A376.30905@viscovery.net>

On Friday 19 September 2008 17:04:54 Johannes Sixt wrote:
> Alexander Gavrilov schrieb:
> > Also, it should work in the patch mode as well: it reads the patch as
> > binary, and decodes each line separately, based on the encoding
> > determined for the current file.
> 
> This is great. But we'll have to see how this works on a multi-file diff
> on Windows. (I sense slowness.)
> 

Yes, yesterday I noticed that when the patch is very big, like when the
index has got out of sync, and gitk claims local changes in all of the git-gui
repository (>1000 files), first view is slow even on Linux.

I made a patch to optimize attribute lookup. I'm afraid that further optimization
is impossible without interface changes in git-check-attr, or reimplementing
the attribute parser in Tcl.

--- >8 ---
From: Alexander Gavrilov <angavrilov@gmail.com>
Subject: [PATCH] gitk: Implement batch lookup and caching of encoding attrs.

When the diff contains thousands of files, calling git-check-attr
once per file is very slow. With this patch gitk does attribute
lookup in batches of 30 files while reading the diff file list,
which leads to a very noticeable speedup.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
 gitk |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/gitk b/gitk
index 1355aa2..6fc1e90 100755
--- a/gitk
+++ b/gitk
@@ -6530,6 +6530,7 @@ proc gettreediffline {gdtf ids} {
     global cmitmode vfilelimit curview limitdiffs
 
     set nr 0
+    set sublist {}
     while {[incr nr] <= 1000 && [gets $gdtf line] >= 0} {
 	set i [string first "\t" $line]
 	if {$i >= 0} {
@@ -6539,8 +6540,10 @@ proc gettreediffline {gdtf ids} {
 	    }
 	    set file [encoding convertfrom $file]
 	    lappend treediff $file
+	    lappend sublist $file
 	}
     }
+    cache_gitattr encoding $sublist
     if {![eof $gdtf]} {
 	return [expr {$nr >= 1000? 2: 1}]
     }
@@ -9839,18 +9842,47 @@ proc tcl_encoding {enc} {
 }
 
 proc gitattr {path attr default} {
-	if {[catch {set r [exec git check-attr $attr -- $path]}]} {
+	global path_attr_cache
+	if {[info exists path_attr_cache($attr,$path)]} {
+		set r $path_attr_cache($attr,$path)
+	} elseif {[catch {set r [exec git check-attr $attr -- $path]}]} {
 		set r unspecified
 	} else {
 		set r [join [lrange [split $r :] 2 end] :]
 		regsub {^ } $r {} r
 	}
+	set path_attr_cache($attr,$path) $r
 	if {$r eq {unspecified}} {
 		return $default
 	}
 	return $r
 }
 
+proc cache_gitattr {attr pathlist} {
+	global path_attr_cache
+	set newlist {}
+	foreach path $pathlist {
+		if {[info exists path_attr_cache($attr,$path)]} continue
+		lappend newlist $path
+	}
+	while {$newlist ne {}} {
+		set head [lrange $newlist 0 29]
+		set newlist [lrange $newlist 30 end]
+		if {![catch {set rlist [eval exec git check-attr $attr -- $head]}]} {
+			foreach row [split $rlist "\n"] {
+				set cols [split $row :]
+				set path [lindex $cols 0]
+				set value [join [lrange $cols 2 end] :]
+				if {[string index $path 0] eq "\""} {
+					set path [encoding convertfrom [lindex $path 0]]
+				}
+				set path_attr_cache($attr,$path) $value
+			}
+		}
+		update
+	}
+}
+
 proc get_path_encoding {path} {
 	global gui_encoding
 	set tcl_enc [tcl_encoding $gui_encoding]
-- 
1.6.0.20.g6148bc

^ permalink raw reply related

* Re* [RFC/PATCH] extend meaning of "--root" option to index comparisons
From: Junio C Hamano @ 2008-09-21 18:48 UTC (permalink / raw)
  To: Jeff King; +Cc: Anatol Pomozov, sverre, Git Mailing List
In-Reply-To: <20080921135616.GA25238@sigill.intra.peff.net>

Jeff King <peff@peff.net> writes:

> On Fri, Sep 19, 2008 at 01:27:46PM -0700, Junio C Hamano wrote:
> ...
>>  (2) "--root" is about "do we show a creation event as a huge diff from
>>      emptyness?".  Yes, we turn it on for "git log" but it does not have
>>      anything to do with the issue of yet to be born branch, where there
>>      isn't even a big creation event yet.
>
> What about index comparisons? What should an index comparison to a
> branch yet-to-be-born look like? Right now it is an error.

It should be an error, because that is _not_ even an comparison.  At least
at diff-index level.

The diff wrapper UI could do something different, though.  And an obvious
thing to do is to give a fake creation event.

The current output feels perfectly sensible to me.

	$ mkdir d; cd d; tar xf .../t.tar; git init; git add .
	$ git diff --cached
        fatal: No HEAD commit to compare with (yet)

The alternative is no different from "find . -type f | xargs cat" from the
point of view of reviewability.  To make sure you have what you want in
your initial revision, so that you can get things right from the start,
you would want to check things like:

	$ tar df .../t.tar ;# did I change anything?
        $ git ls-files ;# do I have what I want?
        $ git clean -n ;# have I missed anything?

By allowing an auto-fallback to the comparison with an empty tree object, 
you are giving these possibilities:

	$ git diff --cached --stat
	$ git diff --cached --name-only

but the latter is already available from ls-files anyway, and the former
does not feel so interesting.  

In exchange, we lose the reminder to the user that this is a creation
event.  An interactive user (remember, I am not talking about diff-index
here, but diff front-end) may want to treat it specially perhaps by being
extra careful.  If there were no downsides like this in "fall back to
comparing with an empty tree" approach, I wouldn't hesitate to agree it is
a good idea, though.

>> I am reluctant to agree with the opinion that "git log" should be _silent_
>> in a world without any history.
>
> It feels a bit more Unix-y to me. That is, if I am asking for some set
> of commits, and there are _no_ commits in the set, then I expect no
> output.

To this, I am inclined to agree.  We could do something like the attached
patch, but there is a caveat.

There may be commands that

 (1) cannot sanely operate without any positive ref;

 (2) give default "HEAD";

 (3) do not have its own input verification to make sure there is at least
     one positive ref, because they have been relying on revision
     machinery to die() with the existing check.

and this patch is actively breaking them.  If people like this approach
(and I probably will join them), commands that match the above criteria
need to be identified and fixed by setting revs->require_valid_def.

 revision.c |   22 ++++++++++++++++++----
 revision.h |    5 ++++-
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git i/revision.c w/revision.c
index 2f646de..5ce7795 100644
--- i/revision.c
+++ w/revision.c
@@ -1295,12 +1295,26 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 		prepare_show_merge(revs);
 	if (revs->def && !revs->pending.nr) {
 		unsigned char sha1[20];
-		struct object *object;
 		unsigned mode;
-		if (get_sha1_with_mode(revs->def, sha1, &mode))
+		int flag;
+		if (!get_sha1_with_mode(revs->def, sha1, &mode)) {
+			struct object *object;
+			object = get_reference(revs, revs->def, sha1, 0);
+			add_pending_object_with_mode(revs, object, revs->def, mode);
+		} else if (!revs->require_valid_def &&
+			   !strcmp(revs->def, "HEAD") &&
+			   resolve_ref(revs->def, sha1, 0, &flag) &&
+			   (flag & REF_ISSYMREF)) {
+			/*
+			 * Most commands can operate on an unborn branch
+			 * without an explicit ref parameter as if no
+			 * positive ref was specified (as opposed to the
+			 * traditional behaviour of barfing on invalid HEAD).
+			 */
+			;
+		} else {
 			die("bad default revision '%s'", revs->def);
-		object = get_reference(revs, revs->def, sha1, 0);
-		add_pending_object_with_mode(revs, object, revs->def, mode);
+		}
 	}
 
 	/* Did the user ask for any diff output? Run the diff! */
diff --git i/revision.h w/revision.h
index 2fdb2dd..7890fb7 100644
--- i/revision.h
+++ w/revision.h
@@ -30,7 +30,10 @@ struct rev_info {
 	const char *prefix;
 	const char *def;
 	void *prune_data;
-	unsigned int early_output;
+
+	/* Miscellaneous */
+	unsigned int	early_output:1,
+			require_valid_def:1;
 
 	/* Traversal flags */
 	unsigned int	dense:1,

^ permalink raw reply related

* Re: [funny] "git checkout -t origin/xyzzy" seems to misbehave
From: Daniel Barkalow @ 2008-09-21 18:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Johannes Schindelin
In-Reply-To: <7v1vzd29i3.fsf@gitster.siamese.dyndns.org>

On Sun, 21 Sep 2008, Junio C Hamano wrote:

> When you
> 
>  * are on a branch "foo" that is not "bar",
>  * have "origin/bar",
>  * and already have a local branch "bar",
> 
> "git checkout -t origin/bar" seems to misbehave.

It's always been the case if the thing that fails is changing the ref for 
HEAD, you're left with the index and working tree changed but the ref 
unchanged. OTOH, the C conversion lost the early checks that a new branch 
name is plausible in advance of trying anything.

commit c36a025b20ac752f8960bc36dcbab98ca1824657
Author: Daniel Barkalow <barkalow@iabervon.org>
Date:   Sun Sep 21 14:25:31 2008 -0400

    Check early that a new branch is new and valid
    
    If you fail to update refs to change branches in checkout, your index
    and working tree are left already updated. We don't have an easy way
    to undo this, but at least we can check things that would make the
    creation of a new branch fail. These checks were in the shell version,
    and were lost in the C conversion.
    
    The messages are from the shell version, and should probably be made nicer.
    
    Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>

diff --git a/builtin-checkout.c b/builtin-checkout.c
index 9377a1c..4497b70 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -580,6 +580,18 @@ no_reference:
 		return checkout_paths(source_tree, pathspec);
 	}
 
+	if (opts.new_branch) {
+		struct strbuf buf;
+		strbuf_init(&buf, 0);
+		strbuf_addstr(&buf, "refs/heads/");
+		strbuf_addstr(&buf, opts.new_branch);
+		if (!get_sha1(buf.buf, rev))
+			die("git checkout: branch %s already exists", opts.new_branch);
+		if (check_ref_format(buf.buf))
+			die("git checkout: we do not like '%s' as a branch name.", opts.new_branch);
+		strbuf_release(&buf);
+	}
+
 	if (new.name && !new.commit) {
 		die("Cannot switch branch to a non-commit.");
 	}

^ permalink raw reply related

* Re: Git-1.6.0.2-preview20080921 on Windows
From: Alexander Gavrilov @ 2008-09-21 18:19 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: msysGit, Git Mailing List
In-Reply-To: <82166911-C34F-439C-A2F3-CEBD7346A1D6@zib.de>


On Sun, Sep 21, 2008 at 9:30 PM, Steffen Prohaska <prohaska@zib.de> wrote:
> Git-1.6.0.2-preview20080921 for Windows is available at
>
>    http://code.google.com/p/msysgit/downloads
>
> The version installed is based on Junio's current 'maint' (cc185a6a8a)
> plus the patch series I sent today, see
>
>   http://article.gmane.org/gmane.comp.version-control.git/92605
>
> The new installer is not yet featured on the msysgit homepage, because
> the installer contains the new "libexec/git-core" layout, which has not
> been tested much.  I'll wait a few days to see if the new layout works.
> If hear nothing bad, I'll move the "Featured" flag to 1.6.0.2.

You forgot to merge my build of the Cygwin kill utility for MSys.
Available here:

http://repo.or.cz/w/msysgit.git?a=log;h=refs/heads/mob


Also, when I start git-gui from an empty repository, or try to amend
the root commit, I get:


Assertion failed: argv0_path, file exec_cmd.c, line 15

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Assertion failed: argv0_path, file exec_cmd.c, line 15

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
    while executing
"exec {C:/Program Files/Git/libexec/git-core/git-mktree.exe} << {}"
    ("eval" body line 1)
    invoked from within
"eval exec $opt $cmdp $args"
    (procedure "git" line 23)
    invoked from within
"git mktree << {}"
    (procedure "PARENT" line 9)
    invoked from within
"PARENT"
    (procedure "rescan_stage2" line 25)
    invoked from within
"rescan_stage2 filebf7840 ui_ready"


I get the same error if I simply run 'git mktree' as well.

Alexander

^ permalink raw reply

* Re: ignoring files/directories in git
From: Dmitry Potapov @ 2008-09-21 17:42 UTC (permalink / raw)
  To: mwolfe38; +Cc: git
In-Reply-To: <19596152.post@talk.nabble.com>

On Sun, Sep 21, 2008 at 09:54:38AM -0700, mwolfe38 wrote:
> 
> I've added them to the .gitignore file which I have in the initial directory
> of the repository
> The contents of my gitignore are:
> 
> .settings
> .cache
> cache/
> log/
> .project
> 
> However, if I do 
> git add .
> It will add the files from cache and log anyways.
> I know git add . will add anything that hasn't been added but shouldn't it
> ignore files in .gitignore?

It does ignore files in .gitignore. What version of Git do you use?
IIRC, some old ones did not like the slash at the end of name.

Dmitry

^ permalink raw reply

* Re: ignoring files/directories in git
From: mwolfe38 @ 2008-09-21 17:42 UTC (permalink / raw)
  To: git
In-Reply-To: <19596152.post@talk.nabble.com>


Fixed, by removing the trailing / in the names it will then ignore all files
in that directory,
so now i just have
cache 
log
instead of 
cache/ and log/




mwolfe38 wrote:
> 
> I'm working on a project by myself and using git mostly just to learn
> about it.
> In my project I have several directories I want to have git ignore. One of
> them being
> cache/ and the other log/
> I've added them to the .gitignore file which I have in the initial
> directory of the repository
> The contents of my gitignore are:
> 
> .settings
> .cache
> cache/
> log/
> .project
> 
> However, if I do 
> git add .
> It will add the files from cache and log anyways.
> I know git add . will add anything that hasn't been added but shouldn't it
> ignore files in .gitignore?
> If not, what is the point, I would just ignore them manually anyways. 
> The main reason i like doing git add .
> is because i'm using symfony php framework which makes good use of scripts
> which generates lots if initial files for you and thus adding one at a
> time would be a pain.
> 
> Any idea what might be going on here?  I thought maybe I had added those
> directories before putting them in .gitignore so i used git rm -r to
> remove them but they still show back up with doing git add .
> 
> Thanks in advance
> 

-- 
View this message in context: http://www.nabble.com/ignoring-files-directories-in-git-tp19596152p19596620.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply

* [CORRECTION] Git-1.6.0.2-preview20080921 on Windows
From: Steffen Prohaska @ 2008-09-21 17:33 UTC (permalink / raw)
  To: msysGit, Git Mailing List
In-Reply-To: <82166911-C34F-439C-A2F3-CEBD7346A1D6@zib.de>

Git-1.6.0.2-preview20080921 for Windows is available at

    http://code.google.com/p/msysgit/downloads

The version installed is based on Junio's current 'maint' (cc185a6a8a)
plus the patch series I sent today, see

    http://article.gmane.org/gmane.comp.version-control.git/96409

The new installer is not yet featured on the msysgit homepage, because
the installer contains the new "libexec/git-core" layout, which has not
been tested much.  I'll wait a few days to see if the new layout works.
If hear nothing bad, I'll move the "Featured" flag to 1.6.0.2.

	Steffen

^ permalink raw reply

* Git-1.6.0.2-preview20080921 on Windows
From: Steffen Prohaska @ 2008-09-21 17:30 UTC (permalink / raw)
  To: msysGit, Git Mailing List

Git-1.6.0.2-preview20080921 for Windows is available at

     http://code.google.com/p/msysgit/downloads

The version installed is based on Junio's current 'maint' (cc185a6a8a)
plus the patch series I sent today, see

    http://article.gmane.org/gmane.comp.version-control.git/92605

The new installer is not yet featured on the msysgit homepage, because
the installer contains the new "libexec/git-core" layout, which has not
been tested much.  I'll wait a few days to see if the new layout works.
If hear nothing bad, I'll move the "Featured" flag to 1.6.0.2.

	Steffen

^ permalink raw reply

* Re: ignoring files/directories in git
From: Boaz Harrosh @ 2008-09-21 17:19 UTC (permalink / raw)
  To: mwolfe38; +Cc: git
In-Reply-To: <19596152.post@talk.nabble.com>

mwolfe38 wrote:
> I'm working on a project by myself and using git mostly just to learn about
> it.
> In my project I have several directories I want to have git ignore. One of
> them being
> cache/ and the other log/
> I've added them to the .gitignore file which I have in the initial directory
> of the repository
> The contents of my gitignore are:
> 
> .settings
> .cache
> cache/
> log/

If I use "patches/" in my .gitignore file and then git-status 
then I get all these extra files in the "Untracked files:" section
but if I use plain "patches" (No slash at end) then it works. Sounds
like a bug to me but it sure is a workaround.

> .project
> 
> However, if I do 
> git add .
> It will add the files from cache and log anyways.
> I know git add . will add anything that hasn't been added but shouldn't it
> ignore files in .gitignore?
> If not, what is the point, I would just ignore them manually anyways. 
> The main reason i like doing git add .
> is because i'm using symfony php framework which makes good use of scripts
> which generates lots if initial files for you and thus adding one at a time
> would be a pain.
> 
> Any idea what might be going on here?  I thought maybe I had added those
> directories before putting them in .gitignore so i used git rm -r to remove
> them but they still show back up with doing git add .
> 
> Thanks in advance

Boaz

^ permalink raw reply

* Re: Re* [RFC/PATCH] extend meaning of "--root" option to index comparisons
From: Jakub Narebski @ 2008-09-21 17:04 UTC (permalink / raw)
  To: git
In-Reply-To: <3665a1a00809210858r1c494d22p77b5e9964c06424e@mail.gmail.com>

Anatol Pomozov wrote:

> What about following algorithm. HEAD points to ref and ref is not
> created yet. Additional check could be
>  a) there are no other refs
>  or/and b) object database is empty

What about the case when you create _independent_ branch (additional
root, i.e. parentless commit), like 'html', 'man' and 'todo' branches
in git.git repository?  Neither a) nor b) applies, and I don't consider
such situation a bug.  HEAD should be in proper symref format:
"ref: refs/heads/<branchname>".

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* ignoring files/directories in git
From: mwolfe38 @ 2008-09-21 16:54 UTC (permalink / raw)
  To: git


I'm working on a project by myself and using git mostly just to learn about
it.
In my project I have several directories I do not want to have git ignore.
One of them being
cache/ and the other log/
I've added them to the .gitignore file which I have in the initial directory
of the repository
The contents of my gitignore are:

.settings
.cache
cache/
log/
.project

However, if I do 
git add .
It will add the files from cache and log anyways.
I know git add . will add anything that hasn't been added but shouldn't it
ignore files in .gitignore?
If not, what is the point, I would just ignore them manually anyways. 
The main reason i like doing git add .
is because i'm using symfony php framework which makes good use of scripts
which generates lots if initial files for you and thus adding one at a time
would be a pain.

Any idea what might be going on here?  I thought maybe I had added those
directories before putting them in .gitignore so i used git rm -r to remove
them but they still show back up with doing git add .

Thanks in advance
-- 
View this message in context: http://www.nabble.com/ignoring-files-directories-in-git-tp19596152p19596152.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply

* [PATCH 5/7] Add calls to git_extract_argv0_path() in programs that call git_config_*
From: Steffen Prohaska @ 2008-09-21 16:24 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Junio C Hamano, Johannes Schindelin, Steffen Prohaska
In-Reply-To: <1222014278-11071-5-git-send-email-prohaska@zib.de>

Programs that use git_config need to find the global
configuration.  When runtime prefix computation is enabled, this
requires that git_extract_argv0_path() is called early in the
program's main().

This commit adds the necessary calls in the programs that use
git_config.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 daemon.c      |    3 +++
 fast-import.c |    4 ++++
 hash-object.c |    4 ++++
 index-pack.c  |    4 ++++
 unpack-file.c |    4 ++++
 var.c         |    4 ++++
 6 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/daemon.c b/daemon.c
index 0e026f6..c46ddd4 100644
--- a/daemon.c
+++ b/daemon.c
@@ -956,6 +956,9 @@ int main(int argc, char **argv)
 	gid_t gid = 0;
 	int i;
 
+	if (argv[0] && *argv[0])
+		git_extract_argv0_path(argv[0]);
+
 	for (i = 1; i < argc; i++) {
 		char *arg = argv[i];
 
diff --git a/fast-import.c b/fast-import.c
index ccdf2e5..8a74f38 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -150,6 +150,7 @@ Format of STDIN stream:
 #include "refs.h"
 #include "csum-file.h"
 #include "quote.h"
+#include "exec_cmd.h"
 
 #define PACK_ID_BITS 16
 #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
@@ -2395,6 +2396,9 @@ int main(int argc, const char **argv)
 {
 	unsigned int i, show_stats = 1;
 
+	if (argv[0] && *argv[0])
+		git_extract_argv0_path(argv[0]);
+
 	setup_git_directory();
 	git_config(git_pack_config, NULL);
 	if (!pack_compression_seen && core_compression_seen)
diff --git a/hash-object.c b/hash-object.c
index a4d127c..6d9f948 100644
--- a/hash-object.c
+++ b/hash-object.c
@@ -8,6 +8,7 @@
 #include "blob.h"
 #include "quote.h"
 #include "parse-options.h"
+#include "exec_cmd.h"
 
 static void hash_fd(int fd, const char *type, int write_object, const char *path)
 {
@@ -83,6 +84,9 @@ int main(int argc, const char **argv)
 
 	type = blob_type;
 
+	if (argv[0] && *argv[0])
+		git_extract_argv0_path(argv[0]);
+
 	git_config(git_default_config, NULL);
 
 	argc = parse_options(argc, argv, hash_object_options, hash_object_usage, 0);
diff --git a/index-pack.c b/index-pack.c
index a6e91fe..c6ac0e6 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -8,6 +8,7 @@
 #include "tree.h"
 #include "progress.h"
 #include "fsck.h"
+#include "exec_cmd.h"
 
 static const char index_pack_usage[] =
 "git index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] [--strict] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
@@ -877,6 +878,9 @@ int main(int argc, char **argv)
 	unsigned char pack_sha1[20];
 	int nongit = 0;
 
+	if (argv[0] && *argv[0])
+		git_extract_argv0_path(argv[0]);
+
 	setup_git_directory_gently(&nongit);
 	git_config(git_index_pack_config, NULL);
 
diff --git a/unpack-file.c b/unpack-file.c
index bcdc8bb..f8bfda7 100644
--- a/unpack-file.c
+++ b/unpack-file.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "blob.h"
+#include "exec_cmd.h"
 
 static char *create_temp_file(unsigned char *sha1)
 {
@@ -25,6 +26,9 @@ int main(int argc, char **argv)
 {
 	unsigned char sha1[20];
 
+	if (argv[0] && *argv[0])
+		git_extract_argv0_path(argv[0]);
+
 	if (argc != 2)
 		usage("git-unpack-file <sha1>");
 	if (get_sha1(argv[1], sha1))
diff --git a/var.c b/var.c
index f1eb314..33457dc 100644
--- a/var.c
+++ b/var.c
@@ -4,6 +4,7 @@
  * Copyright (C) Eric Biederman, 2005
  */
 #include "cache.h"
+#include "exec_cmd.h"
 
 static const char var_usage[] = "git var [-l | <variable>]";
 
@@ -56,6 +57,9 @@ int main(int argc, char **argv)
 		usage(var_usage);
 	}
 
+	if (argv[0] && *argv[0])
+		git_extract_argv0_path(argv[0]);
+
 	setup_git_directory_gently(&nongit);
 	val = NULL;
 
-- 
1.6.0.2.GIT

^ permalink raw reply related

* [PATCH 0/7 v2] prefix discovery at runtime (on Windows)
From: Steffen Prohaska @ 2008-09-21 16:24 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Junio C Hamano, Johannes Schindelin

This is the second version of the patch series that fixes discovery of
the installation prefix at runtime on Windows.  It introduces a compile
flag RUNTIME_PREFIX, which can be set to explicitly request prefix
computation at runtime.

You can find the first version at

  http://article.gmane.org/gmane.comp.version-control.git/92605

I mainly improved some of the commit messages and rebased to the
current master.

PATCH 6/7 might need further discussion.  Hannes noted that PATCH 6/7
touches a sensible part of exec_cmd.c, although he thinks that the
proposed change might be good.  See
http://article.gmane.org/gmane.comp.version-control.git/92626 for his
comment.  I did not modify PATCH 6/7.

        Steffen

 [PATCH 1/7] Windows: Add workaround for MSYS' path conversion
 [PATCH 2/7] system_path(): Add prefix computation at runtime if RUNTIME_PREFIX set
 [PATCH 3/7] Refactor git_set_argv0_path() to git_extract_argv0_path()
 [PATCH 4/7] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.
 [PATCH 5/7] Add calls to git_extract_argv0_path() in programs that call git_config_*
 [PATCH 6/7] Modify setup_path() to only add git_exec_path() to PATH
 [PATCH 7/7] Windows: Revert to default paths and convert them by RUNTIME_PREFIX

^ permalink raw reply

* [PATCH 3/7] Refactor git_set_argv0_path() to git_extract_argv0_path()
From: Steffen Prohaska @ 2008-09-21 16:24 UTC (permalink / raw)
  To: Johannes Sixt
  Cc: git, Junio C Hamano, Johannes Schindelin, Steve Haslam,
	Steffen Prohaska
In-Reply-To: <1222014278-11071-3-git-send-email-prohaska@zib.de>

From: Steve Haslam <shaslam@lastminute.com>

This commit moves the code that computes the dirname of argv[0]
from git.c's main() to git_set_argv0_path() and renames the function
to git_extract_argv0_path().  This makes the code in git.c's main
less cluttered, and we can use the direname computation from other
main() functions too.

[spr: split Steve's original commit and wrote new commit message. ]

Signed-off-by: Steve Haslam <shaslam@lastminute.com>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 exec_cmd.c |   15 +++++++++++++--
 exec_cmd.h |    2 +-
 git.c      |   20 +++++---------------
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/exec_cmd.c b/exec_cmd.c
index 9fa89b8..46ebf7e 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -54,9 +54,20 @@ const char *system_path(const char *path)
 	return path;
 }
 
-void git_set_argv0_path(const char *path)
+const char *git_extract_argv0_path(const char *argv0)
 {
-	argv0_path = path;
+	const char *slash = argv0 + strlen(argv0);
+
+	do
+		--slash;
+	while (slash >= argv0 && !is_dir_sep(*slash));
+
+	if (slash >= argv0) {
+		argv0_path = xstrndup(argv0, slash - argv0);
+		return slash + 1;
+	}
+
+	return argv0;
 }
 
 void git_set_argv_exec_path(const char *exec_path)
diff --git a/exec_cmd.h b/exec_cmd.h
index 594f961..392e903 100644
--- a/exec_cmd.h
+++ b/exec_cmd.h
@@ -2,7 +2,7 @@
 #define GIT_EXEC_CMD_H
 
 extern void git_set_argv_exec_path(const char *exec_path);
-extern void git_set_argv0_path(const char *path);
+extern const char* git_extract_argv0_path(const char *path);
 extern const char* git_exec_path(void);
 extern void setup_path(void);
 extern const char **prepare_git_cmd(const char **argv);
diff --git a/git.c b/git.c
index 905acc2..b2b95e8 100644
--- a/git.c
+++ b/git.c
@@ -416,23 +416,13 @@ static void execv_dashed_external(const char **argv)
 
 int main(int argc, const char **argv)
 {
-	const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
-	char *slash = (char *)cmd + strlen(cmd);
+	const char *cmd;
 	int done_alias = 0;
 
-	/*
-	 * Take the basename of argv[0] as the command
-	 * name, and the dirname as the default exec_path
-	 * if we don't have anything better.
-	 */
-	do
-		--slash;
-	while (cmd <= slash && !is_dir_sep(*slash));
-	if (cmd <= slash) {
-		*slash++ = 0;
-		git_set_argv0_path(cmd);
-		cmd = slash;
-	}
+	if (argv[0] && *argv[0])
+		cmd = git_extract_argv0_path(argv[0]);
+	else
+		cmd = "git-help";
 
 	/*
 	 * "git-xxxx" is the same as "git xxxx", but we obviously:
-- 
1.6.0.2.GIT

^ permalink raw reply related

* Re: Problems with git over http
From: Matthieu Moy @ 2008-09-21 16:25 UTC (permalink / raw)
  To: Sean Davis; +Cc: git
In-Reply-To: <264855a00809201013h6003abbfr9bbdd20c92e9201d@mail.gmail.com>

"Sean Davis" <sdavis2@mail.nih.gov> writes:

> I am new to git and trying to set up a remote repository over http.  I
> have configured apache2 and the bare, empty repository.  Using curl, I
> can get the file HEAD without a password (seems .netrc is correct?).
> However, when I try to push to the repository, I get the following:
>
> sdavis@lestrade:/tmp/testing> git push
> http://sdavis@watson.nci.nih.gov/git/sean_git.git/ master
> fatal: exec http-push failed.

Do you have git-http-push somewhere? What does "git http-push" say?

Probably you have a version of Git compiled with a too old libcurl
(IIRC, it could have "worked", but a bug in the old libcurl could
cause repository corruption, and therefore, git refuses to build
http-push with such version of libcurl).

-- 
Matthieu

^ permalink raw reply

* [PATCH 2/7] system_path(): Add prefix computation at runtime if RUNTIME_PREFIX set
From: Steffen Prohaska @ 2008-09-21 16:24 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Junio C Hamano, Johannes Schindelin, Steffen Prohaska
In-Reply-To: <1222014278-11071-2-git-send-email-prohaska@zib.de>

This commit modifies system_path() to compute the prefix at runtime if
configured to do so.  If RUNTIME_PREFIX is defined, system_path() tries
to strip known directories that executables can be located in from the
path of the executable.  If the path is successfully stripped it is used
as the prefix.  For example, if the executable is "/msysgit/bin/git" and
BINDIR is "/bin", then the prefix is computed as "/msysgit".

We report an error if the runtime prefix computation fails, which can
happen if the executable is not installed at a known location.  The user
should know that the global configuration is not picked up, because this
can cause unexpected behavior.  If we explicitly want to ignore system
wide paths, we can set the environment variable GIT_CONFIG_NOSYSTEM, as
our tests do.

The implementation requires that argv0_path is set up properly, which is
currently the case only on Windows.  argv0_path must point to the
absolute path of the directory of the executable, which is verified by
two calls to assert().  On Windows, the wrapper for main() (see
compat/mingw.h) guarantees that this is the case.  On Unix, further work
is required before RUNTIME_PREFIX can be enabled.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 Makefile   |    3 +++
 exec_cmd.c |   45 +++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 140a2b2..8181f74 100644
--- a/Makefile
+++ b/Makefile
@@ -1006,6 +1006,9 @@ ifdef INTERNAL_QSORT
 	COMPAT_CFLAGS += -DINTERNAL_QSORT
 	COMPAT_OBJS += compat/qsort.o
 endif
+ifdef RUNTIME_PREFIX
+	COMPAT_CFLAGS += -DRUNTIME_PREFIX
+endif
 
 ifdef THREADED_DELTA_SEARCH
 	BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
diff --git a/exec_cmd.c b/exec_cmd.c
index ce6741e..9fa89b8 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -9,11 +9,48 @@ static const char *argv0_path;
 
 const char *system_path(const char *path)
 {
-	if (!is_absolute_path(path) && argv0_path) {
-		struct strbuf d = STRBUF_INIT;
-		strbuf_addf(&d, "%s/%s", argv0_path, path);
-		path = strbuf_detach(&d, NULL);
+#ifdef RUNTIME_PREFIX
+	static const char *prefix;
+
+	assert(argv0_path);
+	assert(is_absolute_path(argv0_path));
+
+	if (!prefix) {
+		const char *strip[] = {
+			GIT_EXEC_PATH,
+			BINDIR,
+			0
+		};
+		const char **s;
+
+		for (s = strip; *s; s++) {
+			const char *sargv = argv0_path + strlen(argv0_path);
+			const char *ss = *s + strlen(*s);
+			while (argv0_path < sargv && *s < ss
+				&& (*sargv == *ss ||
+				    (is_dir_sep(*sargv) && is_dir_sep(*ss)))) {
+				sargv--;
+				ss--;
+			}
+			if (*s == ss) {
+				struct strbuf d = STRBUF_INIT;
+				strbuf_add(&d, argv0_path, sargv - argv0_path);
+				prefix = strbuf_detach(&d, NULL);
+				break;
+			}
+		}
 	}
+
+	if (!prefix) {
+		fprintf(stderr, "RUNTIME_PREFIX requested for path '%s', "
+				"but prefix computation failed.\n", path);
+		return path;
+	}
+
+	struct strbuf d = STRBUF_INIT;
+	strbuf_addf(&d, "%s/%s", prefix, path);
+	path = strbuf_detach(&d, NULL);
+#endif
 	return path;
 }
 
-- 
1.6.0.2.GIT

^ permalink raw reply related

* [PATCH 6/7] Modify setup_path() to only add git_exec_path() to PATH
From: Steffen Prohaska @ 2008-09-21 16:24 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Junio C Hamano, Johannes Schindelin, Steffen Prohaska
In-Reply-To: <1222014278-11071-6-git-send-email-prohaska@zib.de>

We should search git programs only in the highest-priority location.
The old code added the directories "argv_exec_path",
"getenv(EXEC_PATH_ENVIRONMENT)", and "system_path(GIT_EXEC_PATH)" to
PATH.  The same order is implemented in git_exec_path(), which returns
the highest priority location to search for executables.  If the user
explicitly overrides the default location (by --exec-path or
GIT_EXEC_PATH) we can expect that all the required programs are there.
It does not make sense that only some of the required programs are
located at the highest priority location and other programs are picked
up from a lower priority exec-path.  If exec-path is overridden
a complete set of commands should be provided, otherwise several
different versions might easily get mixed, which is likely to spread
confusion.

Accessing the location with highest priority only is also required for
testing of executables built with RUNTIME_PREFIX.  Calling
system_path(GIT_EXEC_PATH) is avoided if a higher-priority location is
provided, which is the case for the tests.  The call to system_path()
must be avoided, if RUNTIME_PREFIX is set, because the call would fail
if the executable is not installed at its final destination.  But we
test before installing.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 exec_cmd.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/exec_cmd.c b/exec_cmd.c
index 46ebf7e..2a86670 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -111,9 +111,7 @@ void setup_path(void)
 
 	strbuf_init(&new_path, 0);
 
-	add_path(&new_path, argv_exec_path);
-	add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));
-	add_path(&new_path, system_path(GIT_EXEC_PATH));
+	add_path(&new_path, git_exec_path());
 	add_path(&new_path, argv0_path);
 
 	if (old_path)
-- 
1.6.0.2.GIT

^ permalink raw reply related

* [PATCH 7/7] Windows: Revert to default paths and convert them by RUNTIME_PREFIX
From: Steffen Prohaska @ 2008-09-21 16:24 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Junio C Hamano, Johannes Schindelin, Steffen Prohaska
In-Reply-To: <1222014278-11071-7-git-send-email-prohaska@zib.de>

The RUNTIME_PREFIX mechanism allows us to use the default (absolute) paths
on Windows too.  Defining RUNTIME_PREFIX explicitly requests for
translation of paths during runtime, depending on the path to the
executable.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 Makefile |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 8181f74..98278f0 100644
--- a/Makefile
+++ b/Makefile
@@ -767,6 +767,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	SNPRINTF_RETURNS_BOGUS = YesPlease
 	NO_SVN_TESTS = YesPlease
 	NO_PERL_MAKEMAKER = YesPlease
+	RUNTIME_PREFIX = YesPlease
 	NO_POSIX_ONLY_PROGRAMS = YesPlease
 	NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
 	COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
@@ -775,9 +776,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/regex/regex.o compat/winansi.o
 	EXTLIBS += -lws2_32
 	X = .exe
-	gitexecdir = ../libexec/git-core
-	template_dir = ../share/git-core/templates/
-	ETC_GITCONFIG = ../etc/gitconfig
 endif
 ifneq (,$(findstring arm,$(uname_M)))
 	ARM_SHA1 = YesPlease
-- 
1.6.0.2.GIT

^ permalink raw reply related

* [PATCH 4/7] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.
From: Steffen Prohaska @ 2008-09-21 16:24 UTC (permalink / raw)
  To: Johannes Sixt
  Cc: git, Junio C Hamano, Johannes Schindelin, Steve Haslam,
	Steffen Prohaska
In-Reply-To: <1222014278-11071-4-git-send-email-prohaska@zib.de>

From: Steve Haslam <shaslam@lastminute.com>

If the user specified the full path to git-upload-pack as the -u option to
"git clone" when cloning a remote repository, and git was not on the default
PATH on the remote machine, git-upload-pack was failing to exec
git-pack-objects.

By making the argv[0] path (if any) available to setup_path(), this will
allow finding the "git" executable in the same directory as
"git-upload-pack". The default built in to exec_cmd.c is to look for "git"
in the ".../libexec/git-core" directory, but it is not installed there (any
longer).

Much the same applies to invoking git-receive-pack from a non-PATH location
using the "--exec" argument to "git push".

[ spr: split Steve's original commit into two commits. ]

Signed-off-by: Steve Haslam <shaslam@lastminute.com>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 receive-pack.c |    3 +++
 upload-pack.c  |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/receive-pack.c b/receive-pack.c
index b81678a..3872180 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -467,6 +467,9 @@ int main(int argc, char **argv)
 	int i;
 	char *dir = NULL;
 
+	if (argv[0] && *argv[0])
+		git_extract_argv0_path(argv[0]);
+
 	argv++;
 	for (i = 1; i < argc; i++) {
 		char *arg = *argv++;
diff --git a/upload-pack.c b/upload-pack.c
index e5adbc0..c469a60 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -616,6 +616,9 @@ int main(int argc, char **argv)
 	int i;
 	int strict = 0;
 
+	if (argv[0] && *argv[0])
+		git_extract_argv0_path(argv[0]);
+
 	for (i = 1; i < argc; i++) {
 		char *arg = argv[i];
 
-- 
1.6.0.2.GIT

^ permalink raw reply related

* [PATCH 1/7] Windows: Add workaround for MSYS' path conversion
From: Steffen Prohaska @ 2008-09-21 16:24 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Junio C Hamano, Johannes Schindelin, Steffen Prohaska
In-Reply-To: <1222014278-11071-1-git-send-email-prohaska@zib.de>

MSYS' automatic path conversion causes problems when passing paths as
defines ('-D' arguments to the compiler).  MSYS tries to be smart and
converts absolute paths to native Windows paths, e.g. if MSYS sees
"/bin" it converts it to "c:/msysgit/bin".  But we want completely
unmodified paths; e.g. if we set bindir in the Makefile to "/bin", the
define BINDIR shall expand to "/bin".  Conversion to absolute Windows
path will takes place later, during runtime.

This commit adds a workaround by replacing "/" with its octal
representation "\057", effectively hiding the path from MSYS' path
conversion mechanism.  MSYS does no longer see the absolute path and
therefore leaves it alone.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 Makefile |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 3c0664a..140a2b2 100644
--- a/Makefile
+++ b/Makefile
@@ -1066,6 +1066,12 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
 htmldir_SQ = $(subst ','\'',$(htmldir))
 prefix_SQ = $(subst ','\'',$(prefix))
 
+ETC_GITCONFIG_SQ_C = $(subst /,\057,$(ETC_GITCONFIG_SQ))
+bindir_SQ_C = $(subst /,\057,$(bindir_SQ))
+gitexecdir_SQ_C = $(subst /,\057,$(gitexecdir_SQ))
+htmldir_SQ_C = $(subst /,\057,$(htmldir_SQ))
+template_dir_SQ_C = $(subst /,\057,$(template_dir_SQ))
+
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
@@ -1117,7 +1123,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
 
 builtin-help.o: builtin-help.c common-cmds.h GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
-		'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
+		'-DGIT_HTML_PATH="$(htmldir_SQ_C)"' \
 		'-DGIT_MAN_PATH="$(mandir_SQ)"' \
 		'-DGIT_INFO_PATH="$(infodir_SQ)"' $<
 
@@ -1224,12 +1230,12 @@ git.o git.spec \
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 
 exec_cmd.o: exec_cmd.c GIT-CFLAGS
-	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
+	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ_C)"' -DBINDIR='"$(bindir_SQ_C)"' $<
 builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
-	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
+	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ_C)"' $<
 
 config.o: config.c GIT-CFLAGS
-	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<
+	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ_C)"' $<
 
 http.o: http.c GIT-CFLAGS
 	$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
-- 
1.6.0.2.GIT

^ permalink raw reply related


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