Git development
 help / color / mirror / Atom feed
* Re: [RFC PATCH] Windows: Assume all file names to be UTF-8 encoded.
From: Peter Krefting @ 2009-03-03 11:56 UTC (permalink / raw)
  To: Dmitry Potapov; +Cc: git
In-Reply-To: <37fcd2780903030143t7abe33d5sb7d8163c3c9bf505@mail.gmail.com>

Dmitry Potapov:

> IMHO, you grossly underestimate what is needed to enable UTF-8 encoding in 
> Windows. AFAIK, Microsoft C runtime library does not support UTF-8, so you 
> have to wrap all C functions taking 'char*' as an input parameter.

I have to wrap all file-related functions, at least.

> For example, think about what is going to happen if Git tries to print a 
> simple error message: fprintf (stderr, "unable to open %s", path);

Yeah. That's a problem. That might be solvable by setting the thread locale 
to something UTF-8 based and have the console window convert to the output 
codepage (that is what it does when you use wprintf and friends).

> And the command-line is not the only source of file names. Some Git 
> commands read list of files from stdin usually though the pipe. In what 
> encoding are they going to be?

Indeed. Pipes are a problem.

-- 
\\// Peter - http://www.softwolves.pp.se/

^ permalink raw reply

* Re: [PATCH] git-clone.txt: document that pushing from a shallow clone may work
From: Adeodato Simó @ 2009-03-03 12:08 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, gitster, Mikael Magnusson, Joey Hess
In-Reply-To: <49AD1B22.6050201@viscovery.net>

* Johannes Sixt [Tue, 03 Mar 2009 12:57:22 +0100]:

> Adeodato Simó schrieb:
> > @@ -133,8 +133,10 @@ then the cloned repository will become corrupt.
> >  --depth <depth>::
> >  	Create a 'shallow' clone with a history truncated to the
> >  	specified number of revisions.  A shallow repository has a
> > -	number of limitations (you cannot clone or fetch from
> > -	it, nor push from nor into it), but is adequate if you
> > +	number of limitations: you cannot clone or fetch from it,
> > +	nor push into it; pushing from it into a regular repository
> > +	may work correctly in some cases, but it is not guaranteed to
> > +	always work.  However, a shallow repository is adequate if you

> Consider a reader who wants to decide whether --depth should or can be
> used in a git clone invocation. Is the new wording helpful? If you don't
> describe those "some cases" in more detail, then we better keep the
> current wording.

Well, I don't know if the set of cases where it'll work can be defined
in detail to a point where it is useful. If it is, then sure, let's do
it.

My point is that if it will work in some cases, then the documentation
should *acknowledge that fact*, because else people will assume the
documentation is wrong, and believe it is intended to work, which is not
the case.

I think doing that is very important, and I hope I'm explaining myself
clearly.

Thanks,

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
«Ara que ets la meva dona, te la fotré fins a la melsa, bacona!»
                -- Terenci Moix, “Chulas y famosas”

^ permalink raw reply

* [PATCHv3 1/2] git submodule: Add test cases for git submodule add
From: Michael J Gruber @ 2009-03-03 12:39 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt, Andrei Thorp, Junio C Hamano
In-Reply-To: <1236083989-20526-1-git-send-email-git@drmicha.warpmail.net>

Add simple test cases for adding and initialising submodules. The
init step is necessary in order to verify the added information.

The second test exposes a known breakage due to './' in the path: git
ls-files simplifies the path but git add does not, which leads to git
init looking for different lines in .gitmodules than git add adds.

The other tests add test cases for '//' and '..' in the path which
currently fail for the same reason.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
The init step test implicitly whether add and init treat the path in the
same way.

 t/t7400-submodule-basic.sh |   49 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index b8cb2df..4f42585 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -47,6 +47,55 @@ test_expect_success 'Prepare submodule testing' '
 	GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
 '
 
+test_expect_success 'Prepare submodule add testing' '
+	submodurl=$(pwd)
+	(
+		mkdir addtest &&
+		cd addtest &&
+		git init
+	)
+'
+
+test_expect_success 'submodule add' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" submod &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with ./ in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with // in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" slashslashsubmod///frotz// &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with /.. in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with ./, /.. and // in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/frotz//.. &&
+		git submodule init
+	)
+'
+
 test_expect_success 'status should fail for unmapped paths' '
 	if git submodule status
 	then
-- 
1.6.2.rc2

^ permalink raw reply related

* [PATCHv3 0/2] git submodule: normalize paths before adding
From: Michael J Gruber @ 2009-03-03 12:39 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt, Andrei Thorp, Junio C Hamano
In-Reply-To: <7vtz6ht9ho.fsf@gitster.siamese.dyndns.org>

This is a rewrite taking into account the advice given by Junio and J6t.
In particular, the tests are good citizens w.r.t. cd'ing around now, the
sed expressions work at least on AIX 4.3.3, and iterations of .. are
tested for and handled correctly.

Sorry I didn't get around to finishing this earlier. Hope this doesn't
mess up any schedules.

Michael J Gruber (2):
  git submodule: Add test cases for git submodule add
  git submodule: Fix adding of submodules at paths with ./, .. and //

 git-submodule.sh           |   15 ++++++++++--
 t/t7400-submodule-basic.sh |   49 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 3 deletions(-)

^ permalink raw reply

* [PATCHv3 2/2] git submodule: Fix adding of submodules at paths with ./, .. and //
From: Michael J Gruber @ 2009-03-03 12:39 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt, Andrei Thorp, Junio C Hamano
In-Reply-To: <1236083989-20526-2-git-send-email-git@drmicha.warpmail.net>

Make 'git submodule add' normalize the submodule path in the
same way as 'git ls-files' does, so that 'git submodule init' looks up
the information in .gitmodules with the same key under which 'git
submodule add' stores it.

This fixes 4 known breakages.
---
Note that sed on AIX does not like comments, which is why they are not
in the sed expression.

 git-submodule.sh           |   15 ++++++++++++---
 t/t7400-submodule-basic.sh |    8 ++++----
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 204aab6..7a25f47 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -167,9 +167,18 @@ cmd_add()
 	;;
 	esac
 
-	# strip trailing slashes from path
-	path=$(echo "$path" | sed -e 's|/*$||')
-
+	# normalize path:
+	# multiple //; leading ./; /./; /../; trailing /
+	path=$(printf '%s/\n' "$path" |
+		sed -e '
+			s|//*|/|g
+			s|^\(\./\)*||
+			s|/\./|/|g
+			:start
+			s|\([^/]*\)/\.\./||g
+			tstart
+			s|/*$||
+		')
 	git ls-files --error-unmatch "$path" > /dev/null 2>&1 &&
 	die "'$path' already exists in the index"
 
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 4f42585..1c82f8c 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -64,7 +64,7 @@ test_expect_success 'submodule add' '
 	)
 '
 
-test_expect_failure 'submodule add with ./ in path' '
+test_expect_success 'submodule add with ./ in path' '
 	(
 		cd addtest &&
 		git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
@@ -72,7 +72,7 @@ test_expect_failure 'submodule add with ./ in path' '
 	)
 '
 
-test_expect_failure 'submodule add with // in path' '
+test_expect_success 'submodule add with // in path' '
 	(
 		cd addtest &&
 		git submodule add "$submodurl" slashslashsubmod///frotz// &&
@@ -80,7 +80,7 @@ test_expect_failure 'submodule add with // in path' '
 	)
 '
 
-test_expect_failure 'submodule add with /.. in path' '
+test_expect_success 'submodule add with /.. in path' '
 	(
 		cd addtest &&
 		git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
@@ -88,7 +88,7 @@ test_expect_failure 'submodule add with /.. in path' '
 	)
 '
 
-test_expect_failure 'submodule add with ./, /.. and // in path' '
+test_expect_success 'submodule add with ./, /.. and // in path' '
 	(
 		cd addtest &&
 		git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/frotz//.. &&
-- 
1.6.2.rc2

^ permalink raw reply related

* import files w/ history
From: Csaba Henk @ 2009-03-03 12:54 UTC (permalink / raw)
  To: git

Hi,

How could I import some files from an unrelated git repo with history?
And if I'd like to use different paths? Eg:

Say the other repo has these files:

lib/trees/rb_tree.{c,h}

and I want to import them into my repo as

include/rb_tree.h
src/rb_tree.c

(In fact I just have a single file to import and I don't want to
vary paths, yet I'm curious about this extended case, too.)

Thanks,
Csaba

^ permalink raw reply

* Re: import files w/ history
From: Jeff King @ 2009-03-03 13:00 UTC (permalink / raw)
  To: Csaba Henk; +Cc: git
In-Reply-To: <slrngqqa4l.1t4t.csaba-ml@beastie.creo.hu>

On Tue, Mar 03, 2009 at 12:54:54PM +0000, Csaba Henk wrote:

> How could I import some files from an unrelated git repo with history?

Just "git pull" from the other repo, which will include all of its
history. If you want to pretend that the other history contains just a
subset of the true history, use "git filter-branch" to rewrite it first.

> And if I'd like to use different paths? Eg:
> 
> Say the other repo has these files:
> 
> lib/trees/rb_tree.{c,h}
> 
> and I want to import them into my repo as
> 
> include/rb_tree.h
> src/rb_tree.c

If you are rewriting the history, you can rename the files as you see
fit. There is even an example of this in "git help filter-branch".

-Peff

^ permalink raw reply

* Re: [TopGit] Multiple concurrent sets of patches
From: martin f krafft @ 2009-03-03 13:03 UTC (permalink / raw)
  To: Jonas Smedegaard, git
In-Reply-To: <20090303113741.GO12820@jones.dk>

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

also sprach Jonas Smedegaard <dr@jones.dk> [2009.03.03.1237 +0100]:
> It seems to me that TopGit is incapable of handling this. That it can 
> only handle patchset against a single branch, and if the need arise for 
> restructuring an additional patchset for e.g. a stable or oldstable 
> branch, then quilt needs to be used manually anyway.

Let me try to understand you: you want TopGit to maintain a single
feature branch against two different source branches? How should
that work? Could you elaborate a bit so that your needs become a bit
more obvious?

Thanks,

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
"i feel sorry for people who don't drink. when they wake up in the
 morning, that's as good as they're going to feel all day."
                                                    -- frank sinatra
 
spamtraps: madduck.bogus@madduck.net

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* Re: [PATCHv3 2/2] git submodule: Fix adding of submodules at paths with ./, .. and //
From: Johannes Sixt @ 2009-03-03 13:08 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: git, Andrei Thorp, Junio C Hamano
In-Reply-To: <1236083989-20526-3-git-send-email-git@drmicha.warpmail.net>

Michael J Gruber schrieb:
> +	# normalize path:
> +	# multiple //; leading ./; /./; /../; trailing /
> +	path=$(printf '%s/\n' "$path" |
> +		sed -e '
> +			s|//*|/|g
> +			s|^\(\./\)*||
> +			s|/\./|/|g
> +			:start
> +			s|\([^/]*\)/\.\./||g

Sorry to say: not yet. This turns "a/b/c/d/../../../d" into "a/b/c/d"
instead of "a/d". Drop the 'g'.

Once this is fixed, I have to ask what should happen with path names like
"../a/b", "../../a/b"? Should there be a warning or error?

Other than that, this expression works on AIX 4.3.3! Note in particular
that '\n' in the printf format string is essential!

> +			tstart
> +			s|/*$||
> +		')

-- Hannes

^ permalink raw reply

* How to submit a big patch?
From: pi song @ 2009-03-03 13:24 UTC (permalink / raw)
  To: git

I have got a  130KB patch. It doesn't really contain big changes but
just I split a big file into smaller files.
 I tried to cut and paste the patch file to gmail but seems gmail
trimmed my file. I tried paste into Outlook Express but my machine was
frozen. How should I submit the patch?

Pi Song

^ permalink raw reply

* Re: How to submit a big patch?
From: Miklos Vajna @ 2009-03-03 13:27 UTC (permalink / raw)
  To: pi song; +Cc: git
In-Reply-To: <1b29507a0903030524xced15ecm6c7a255f7fa12ea4@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 411 bytes --]

On Wed, Mar 04, 2009 at 12:24:31AM +1100, pi song <pi.songs@gmail.com> wrote:
> I have got a  130KB patch. It doesn't really contain big changes but
> just I split a big file into smaller files.
>  I tried to cut and paste the patch file to gmail but seems gmail
> trimmed my file. I tried paste into Outlook Express but my machine was
> frozen. How should I submit the patch?

What about using git-send-email?

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* [PATCH JGIT] Add "compare with Git Index" action.
From: Yann Simon @ 2009-03-03 14:04 UTC (permalink / raw)
  To: Robin Rosenberg, Shawn O. Pearce; +Cc: git

In the Compare With... menu, the "Git Index" action opens
a diff editor that compares the workspace version of a file and its
index version.

The local file can be modified and saved.

The staged version can be modified and saved. This updates the index.
For this, add methods into GitIndex to allow to specify a content
different from the file.

Signed-off-by: Yann Simon <yann.simon.fr@gmail.com>
---
Change compare to last sent:
Labels modified according to suggestion from Robin Rosenberg

 .../core/internal/storage/GitFileRevision.java     |   11 ++
 org.spearce.egit.ui/plugin.properties              |    3 +
 org.spearce.egit.ui/plugin.xml                     |    7 +
 .../spearce/egit/ui/internal/EditableRevision.java |  157 ++++++++++++++++++++
 .../GitCompareFileRevisionEditorInput.java         |   36 +++--
 .../internal/actions/CompareWithIndexAction.java   |  119 +++++++++++++++
 .../src/org/spearce/jgit/lib/GitIndex.java         |   65 ++++++++
 7 files changed, 384 insertions(+), 14 deletions(-)
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/EditableRevision.java
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithIndexAction.java

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileRevision.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileRevision.java
index 21ba19e..2f23c7d 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileRevision.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileRevision.java
@@ -49,6 +49,17 @@ public static GitFileRevision inCommit(final Repository db,
 		return new CommitFileRevision(db, commit, path, blobId);
 	}
 
+	/**
+	 * @param db
+	 *            the repository which contains the index to use.
+	 * @param path
+	 *            path of the resource in the index
+	 * @return revision implementation for the given path in the index
+	 */
+	public static GitFileRevision inIndex(final Repository db, final String path) {
+		return new IndexFileRevision(db, path);
+	}
+
 	private final String path;
 
 	GitFileRevision(final String fileName) {
diff --git a/org.spearce.egit.ui/plugin.properties b/org.spearce.egit.ui/plugin.properties
index 58b879f..07d7735 100644
--- a/org.spearce.egit.ui/plugin.properties
+++ b/org.spearce.egit.ui/plugin.properties
@@ -31,6 +31,9 @@ Decorator_description=Shows Git specific information on resources in projects un
 CompareWithRevisionAction_label=Compare With Git Revision
 CompareWithRevisionAction_tooltip=Compare With a Git Revision
 
+CompareWithIndexAction_label=Git Index
+CompareWithIndexAction_tooltip=Compare with Git's index version
+
 ShowResourceInHistoryAction_label=Show in Resource History
 ShowResourceInHistoryAction_tooltip=Show selected files in the resource history view.
 
diff --git a/org.spearce.egit.ui/plugin.xml b/org.spearce.egit.ui/plugin.xml
index 2f23559..678fd73 100644
--- a/org.spearce.egit.ui/plugin.xml
+++ b/org.spearce.egit.ui/plugin.xml
@@ -108,6 +108,13 @@
                label="%CommitAction_label"
                menubarPath="team.main/group1"
                tooltip="%CommitAction_tooltip"/>
+         <action
+               class="org.spearce.egit.ui.internal.actions.CompareWithIndexAction"
+               id="org.spearce.egit.ui.internal.actions.CompareWithIndexAction"
+               label="%CompareWithIndexAction_label"
+               menubarPath="compareWithMenu/gitCompareWithGroup"
+               tooltip="&amp;CompareWithIndexAction_tooltip">
+         </action>
 	  </objectContribution>
 	  <objectContribution
          id="org.spearce.egit.ui.resetto"
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/EditableRevision.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/EditableRevision.java
new file mode 100644
index 0000000..ee064ef
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/EditableRevision.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2009, Yann Simon <yann.simon.fr@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.egit.ui.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.compare.IContentChangeListener;
+import org.eclipse.compare.IContentChangeNotifier;
+import org.eclipse.compare.IEditableContent;
+import org.eclipse.compare.ISharedDocumentAdapter;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.internal.ContentChangeNotifier;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.internal.ui.history.FileRevisionTypedElement;
+import org.eclipse.team.internal.ui.synchronize.EditableSharedDocumentAdapter;
+
+/**
+ * @author simon
+ *
+ */
+public class EditableRevision extends FileRevisionTypedElement implements
+		ITypedElement, IEditableContent, IContentChangeNotifier {
+
+	private byte[] modifiedContent;
+
+	private ContentChangeNotifier fChangeNotifier;
+
+	private EditableSharedDocumentAdapter sharedDocumentAdapter;
+
+	/**
+	 * @param fileRevision
+	 */
+	public EditableRevision(IFileRevision fileRevision) {
+		super(fileRevision);
+	}
+
+	public boolean isEditable() {
+		return true;
+	}
+
+	public ITypedElement replace(ITypedElement dest, ITypedElement src) {
+		return null;
+	}
+
+	@Override
+	public InputStream getContents() throws CoreException {
+		if (modifiedContent != null) {
+			return new ByteArrayInputStream(modifiedContent);
+		}
+		return super.getContents();
+	}
+
+	public void setContent(byte[] newContent) {
+		modifiedContent = newContent;
+		fireContentChanged();
+	}
+
+	/**
+	 * @return the modified content
+	 */
+	public byte[] getModifiedContent() {
+		return modifiedContent;
+	}
+
+	public Object getAdapter(Class adapter) {
+		if (adapter == ISharedDocumentAdapter.class) {
+			return getSharedDocumentAdapter();
+		}
+		return Platform.getAdapterManager().getAdapter(this, adapter);
+	}
+
+	private synchronized ISharedDocumentAdapter getSharedDocumentAdapter() {
+		if (sharedDocumentAdapter == null)
+			sharedDocumentAdapter = new EditableSharedDocumentAdapter(
+					new EditableSharedDocumentAdapter.ISharedDocumentAdapterListener() {
+						public void handleDocumentConnected() {
+						}
+
+						public void handleDocumentFlushed() {
+						}
+
+						public void handleDocumentDeleted() {
+						}
+
+						public void handleDocumentSaved() {
+						}
+
+						public void handleDocumentDisconnected() {
+						}
+					});
+		return sharedDocumentAdapter;
+	}
+
+	public void addContentChangeListener(IContentChangeListener listener) {
+		if (fChangeNotifier == null)
+			fChangeNotifier = new ContentChangeNotifier(this);
+		fChangeNotifier.addContentChangeListener(listener);
+	}
+
+	public void removeContentChangeListener(IContentChangeListener listener) {
+		if (fChangeNotifier != null) {
+			fChangeNotifier.removeContentChangeListener(listener);
+			if (fChangeNotifier.isEmpty())
+				fChangeNotifier = null;
+		}
+	}
+
+	/**
+	 * Notifies all registered <code>IContentChangeListener</code>s of a content
+	 * change.
+	 */
+	protected void fireContentChanged() {
+		if (fChangeNotifier == null || fChangeNotifier.isEmpty()) {
+			return;
+		}
+		fChangeNotifier.fireContentChanged();
+	}
+
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitCompareFileRevisionEditorInput.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitCompareFileRevisionEditorInput.java
index 8aa076f..49d4a42 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitCompareFileRevisionEditorInput.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitCompareFileRevisionEditorInput.java
@@ -11,7 +11,6 @@
 import java.lang.reflect.InvocationTargetException;
 
 import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareEditorInput;
 import org.eclipse.compare.IEditableContent;
 import org.eclipse.compare.IResourceProvider;
 import org.eclipse.compare.ITypedElement;
@@ -34,13 +33,14 @@
 import org.eclipse.team.internal.ui.Utils;
 import org.eclipse.team.internal.ui.history.FileRevisionTypedElement;
 import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
+import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
 import org.eclipse.ui.IWorkbenchPage;
 
 /**
  * The input provider for the compare editor when working on resources
  * under Git control.
  */
-public class GitCompareFileRevisionEditorInput extends CompareEditorInput {
+public class GitCompareFileRevisionEditorInput extends SaveableCompareEditorInput {
 
 	private ITypedElement left;
 	private ITypedElement right;
@@ -52,7 +52,7 @@
 	 * @param page
 	 */
 	public GitCompareFileRevisionEditorInput(ITypedElement left, ITypedElement right, IWorkbenchPage page) {
-		super(new CompareConfiguration());
+		super(new CompareConfiguration(), page);
 		this.left = left;
 		this.right = right;
 	}
@@ -90,9 +90,18 @@ private static void ensureContentsCached(FileRevisionTypedElement left, FileRevi
 	}
 
 	private boolean isLeftEditable(ICompareInput input) {
-		Object left = input.getLeft();
-		if (left instanceof IEditableContent) {
-			return ((IEditableContent) left).isEditable();
+		Object tmpLeft = input.getLeft();
+		return isEditable(tmpLeft);
+	}
+
+	private boolean isRightEditable(ICompareInput input) {
+		Object tmpRight = input.getRight();
+		return isEditable(tmpRight);
+	}
+
+	private boolean isEditable(Object object) {
+		if (object instanceof IEditableContent) {
+			return ((IEditableContent) object).isEditable();
 		}
 		return false;
 	}
@@ -326,12 +335,9 @@ private String getContentIdentifier(ITypedElement element){
 		return TeamUIMessages.CompareFileRevisionEditorInput_2;
 	}
 
-//	/* (non-Javadoc)
-//	 * @see org.eclipse.team.ui.synchronize.LocalResourceCompareEditorInput#fireInputChange()
-//	 */
-//	protected void fireInputChange() {
-//		((DiffNode)getCompareResult()).fireChange();
-//	}
+	@Override
+	protected void fireInputChange() {
+	}
 //
 //	/* (non-Javadoc)
 //	 * @see org.eclipse.team.ui.synchronize.SaveableCompareEditorInput#contentsCreated()
@@ -359,10 +365,12 @@ private LocalResourceTypedElement getLocalElement() {
 		return null;
 	}
 
-	protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+	@Override
+	protected ICompareInput prepareCompareInput(IProgressMonitor monitor)
+			throws InvocationTargetException, InterruptedException {
 		ICompareInput input = createCompareInput();
 		getCompareConfiguration().setLeftEditable(isLeftEditable(input));
-		getCompareConfiguration().setRightEditable(false);
+		getCompareConfiguration().setRightEditable(isRightEditable(input));
 		ensureContentsCached(getLeftRevision(), getRightRevision(), monitor);
 		initLabels(input);
 		setTitle(NLS.bind(TeamUIMessages.SyncInfoCompareInput_title, new String[] { input.getName() }));
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithIndexAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithIndexAction.java
new file mode 100644
index 0000000..3bc24be
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithIndexAction.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2009, Yann Simon <yann.simon.fr@gmail.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.egit.ui.internal.actions;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.IContentChangeListener;
+import org.eclipse.compare.IContentChangeNotifier;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
+import org.spearce.egit.core.internal.storage.GitFileRevision;
+import org.spearce.egit.core.project.RepositoryMapping;
+import org.spearce.egit.ui.internal.EditableRevision;
+import org.spearce.egit.ui.internal.GitCompareFileRevisionEditorInput;
+import org.spearce.jgit.lib.GitIndex;
+import org.spearce.jgit.lib.Repository;
+
+/**
+ * The "compare with index" action. This action opens a diff editor comparing
+ * the file as found in the working directory and the version found in the index
+ * of the repository.
+ */
+@SuppressWarnings("restriction")
+public class CompareWithIndexAction extends RepositoryAction {
+
+	@Override
+	public void execute(IAction action) {
+		final IResource resource = getSelectedResources()[0];
+		final RepositoryMapping mapping = RepositoryMapping.getMapping(resource.getProject());
+		final Repository repository = mapping.getRepository();
+		final String gitPath = mapping.getRepoRelativePath(resource);
+
+		final IFileRevision nextFile = GitFileRevision.inIndex(repository, gitPath);
+
+		final IFile baseFile = (IFile) resource;
+		final ITypedElement base = SaveableCompareEditorInput.createFileElement(baseFile);
+
+		final EditableRevision next = new EditableRevision(nextFile);
+
+		IContentChangeListener listener = new IContentChangeListener() {
+			public void contentChanged(IContentChangeNotifier source) {
+				final byte[] newContent = next.getModifiedContent();
+				try {
+					final GitIndex index = repository.getIndex();
+					final File file = new File(baseFile.getLocation().toString());
+					index.add(mapping.getWorkDir(), file, newContent);
+				} catch (IOException e) {
+					Utils.handleError(getTargetPart().getSite().getShell(), e,
+							"Error during adding to index",
+							"Error during adding to index");
+					return;
+				}
+			}
+		};
+
+		next.addContentChangeListener(listener);
+
+		final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(
+				base, next, null);
+		CompareUI.openCompareEditor(in);
+	}
+
+	@Override
+	public boolean isEnabled() {
+		final IResource[] selectedResources = getSelectedResources();
+		if (selectedResources.length != 1)
+			return false;
+
+		final IResource resource = selectedResources[0];
+		if (!(resource instanceof IFile)) {
+			return false;
+		}
+		final RepositoryMapping mapping = RepositoryMapping.getMapping(resource.getProject());
+		return mapping != null;
+	}
+
+}
\ No newline at end of file
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
index 920a9c9..21b495a 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
@@ -170,6 +170,30 @@ public Entry add(File wd, File f) throws IOException {
 	}
 
 	/**
+	 * Add the content of a file to the index.
+	 *
+	 * @param wd
+	 *            workdir
+	 * @param f
+	 *            the file
+	 * @param content
+	 *            content of the file
+	 * @return a new or updated index entry for the path represented by f
+	 * @throws IOException
+	 */
+	public Entry add(File wd, File f, byte[] content) throws IOException {
+		byte[] key = makeKey(wd, f);
+		Entry e = entries.get(key);
+		if (e == null) {
+			e = new Entry(key, f, 0, content);
+			entries.put(key, e);
+		} else {
+			e.update(f, content);
+		}
+		return e;
+	}
+
+	/**
 	 * Remove a path from the index.
 	 *
 	 * @param wd
@@ -360,6 +384,25 @@ Entry(byte[] key, File f, int stage)
 			flags = (short) ((stage << 12) | name.length); // TODO: fix flags
 		}
 
+		Entry(byte[] key, File f, int stage, byte[] newContent)
+				throws IOException {
+			ctime = f.lastModified() * 1000000L;
+			mtime = ctime; // we use same here
+			dev = -1;
+			ino = -1;
+			if (config_filemode() && File_canExecute(f))
+				mode = FileMode.EXECUTABLE_FILE.getBits();
+			else
+				mode = FileMode.REGULAR_FILE.getBits();
+			uid = -1;
+			gid = -1;
+			size = newContent.length;
+			ObjectWriter writer = new ObjectWriter(db);
+			sha1 = writer.writeBlob(newContent);
+			name = key;
+			flags = (short) ((stage << 12) | name.length); // TODO: fix flags
+		}
+
 		Entry(TreeEntry f, int stage) {
 			ctime = -1; // hmm
 			mtime = -1;
@@ -433,6 +476,28 @@ public boolean update(File f) throws IOException {
 			return modified;
 		}
 
+		/**
+		 * Update this index entry with stat and SHA-1 information if it looks
+		 * like the file has been modified in the workdir.
+		 *
+		 * @param f
+		 *            file in work dir
+		 * @param newContent
+		 *            the new content of the file
+		 * @return true if a change occurred
+		 * @throws IOException
+		 */
+		public boolean update(File f, byte[] newContent) throws IOException {
+			boolean modified = false;
+			size = newContent.length;
+			ObjectWriter writer = new ObjectWriter(db);
+			ObjectId newsha1 = sha1 = writer.writeBlob(newContent);
+			if (!newsha1.equals(sha1))
+				modified = true;
+			sha1 = newsha1;
+			return modified;
+		}
+
 		void write(ByteBuffer buf) {
 			int startposition = buf.position();
 			buf.putInt((int) (ctime / 1000000000L));
-- 
1.6.1.2

^ permalink raw reply related

* Re: [PATCHv3 2/2] git submodule: Fix adding of submodules at paths with ./, .. and //
From: Michael J Gruber @ 2009-03-03 14:09 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Andrei Thorp, Junio C Hamano
In-Reply-To: <49AD2BE6.1000105@viscovery.net>

Johannes Sixt venit, vidit, dixit 03.03.2009 14:08:
> Michael J Gruber schrieb:
>> +	# normalize path:
>> +	# multiple //; leading ./; /./; /../; trailing /
>> +	path=$(printf '%s/\n' "$path" |
>> +		sed -e '
>> +			s|//*|/|g
>> +			s|^\(\./\)*||
>> +			s|/\./|/|g
>> +			:start
>> +			s|\([^/]*\)/\.\./||g
> 
> Sorry to say: not yet. This turns "a/b/c/d/../../../d" into "a/b/c/d"
> instead of "a/d". Drop the 'g'.

Shoot, I thought I had a complete test case...
Thanks for spotting.

> Once this is fixed, I have to ask what should happen with path names like
> "../a/b", "../../a/b"? Should there be a warning or error?

That triggers the error message when trying to git add a submodule which
is not within the current wc. Same before and after the patch, and I
think that's how it should be.

> Other than that, this expression works on AIX 4.3.3! Note in particular
> that '\n' in the printf format string is essential!

I learned that from you ;)

Michael

> 
>> +			tstart
>> +			s|/*$||
>> +		')
> 
> -- Hannes
> 

^ permalink raw reply

* Re: [PATCHv3 2/2] git submodule: Fix adding of submodules at paths with ./, .. and //
From: Johannes Schindelin @ 2009-03-03 14:29 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: git, Johannes Sixt, Andrei Thorp, Junio C Hamano
In-Reply-To: <1236083989-20526-3-git-send-email-git@drmicha.warpmail.net>

Hi,

On Tue, 3 Mar 2009, Michael J Gruber wrote:

> Make 'git submodule add' normalize the submodule path in the
> same way as 'git ls-files' does, so that 'git submodule init' looks up
> the information in .gitmodules with the same key under which 'git
> submodule add' stores it.
> 
> This fixes 4 known breakages.

Maybe it is time to turn this into a builtin?

Ciao,
Dscho

^ permalink raw reply

* git log -Sfoo ignores indentation (whitespace?) changes...
From: "Peter Valdemar Mørch (Lists)" @ 2009-03-03 14:28 UTC (permalink / raw)
  To: git

Commits where only the indentation of 'foo' is changed are not shown 
with "git log -Sfoo". Is there any way to force showing them along with 
other changes involving foo? (E.g. for python, indentation matters!)

Why doesn't the second commit show up in the following?

$ git init

# Create text containing 'line' without whitespace
$ echo 'line' > text
$ git add text
$ git commit -m "first" text

# Here, I add one space of indentation in front of 'line'
$ echo ' line' > text
$ git commit -m "second" text

# git log -Sline shows only the first commit, not the second,
# where the indentation changed.
$ git log -Sline
commit c4481e4b38bb521d91583e5c5a3b2b98f08b7ec0
Author: pvm <pvm@change_me.dk>
Date:   Tue Mar 3 14:45:38 2009 +0100

     first

# But clearly, the second commit *also* has changes
# containing 'line':
$ git log -p HEAD~..HEAD
commit 6cb883409aa9ccda00d7720ee9bf4fa59918c5fd
Author: pvm <pvm@change_me.dk>
Date:   Tue Mar 3 14:45:39 2009 +0100

     second

diff --git a/text b/text
index a999a0c..d650980 100644
--- a/text
+++ b/text
@@ -1 +1 @@
-line
+ line

I would like to see both "first" and "second" somehow - can I do that?

-- 
Peter Valdemar Mørch
http://www.morch.com

^ permalink raw reply related

* Re: [PATCH] git.el: Only show completions from refs/heads
From: Alexandre Julliard @ 2009-03-03 14:48 UTC (permalink / raw)
  To: David Kågedal; +Cc: git
In-Reply-To: <87zlg4qsfk.fsf@krank.kagedal.org>

David Kågedal <davidk@lysator.liu.se> writes:

> Yes, but the typical uses differ a lot. The (overwhelmingly) typical
> use of checkout is to switch to another branch. The typical use of
> cherry-pick is to pick any commit and not treat branch heads
> specially.
>
> So when switching branches, I obviously want a simple way to select
> which branch to switch to. When cherry-picking, I would need some
> simple way of picking any single commit, but that's hard so making it
> easy to pick any named commit is probably the reasonable solution.

It sounds like what you want is to customize it independently for each
operation. That would be better than having two completion functions,
where it's not clear how they differ and why only one can be
customized.

-- 
Alexandre Julliard
julliard@winehq.org

^ permalink raw reply

* Re: [PATCHv3 2/2] git submodule: Fix adding of submodules at paths with ./, .. and //
From: Michael J Gruber @ 2009-03-03 14:58 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Johannes Sixt, Andrei Thorp, Junio C Hamano
In-Reply-To: <alpine.DEB.1.00.0903031529040.6399@intel-tinevez-2-302>

Johannes Schindelin venit, vidit, dixit 03.03.2009 15:29:
> Hi,
> 
> On Tue, 3 Mar 2009, Michael J Gruber wrote:
> 
>> Make 'git submodule add' normalize the submodule path in the
>> same way as 'git ls-files' does, so that 'git submodule init' looks up
>> the information in .gitmodules with the same key under which 'git
>> submodule add' stores it.
>>
>> This fixes 4 known breakages.
> 
> Maybe it is time to turn this into a builtin?

Uhm, you mean all of submodule or just the normalize part? Isn't git
submodule up for some rewriting (.gitmodule...) anyways?

I suggest applying the tests and fix before Bob the In-Builder rolls in.
And no, Bob's not my alter ego...

Michael

^ permalink raw reply

* [PATCHv4 0/2] git submodule: normalize paths before adding
From: Michael J Gruber @ 2009-03-03 15:08 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt, Andrei Thorp, Junio C Hamano
In-Reply-To: <49AD3A29.10404@drmicha.warpmail.net>

This is a rewrite taking into account the advice given by Junio and J6t.
In particular, the tests are good citizens w.r.t. cd'ing around now, the
sed expressions work at least on AIX 4.3.3, and iterations of .. are
tested for and handled correctly.

Sorry I didn't get around to finishing this earlier. Hope this doesn't
mess up any schedules.

v4 incorporates a fix by J6t regarding a spurious g specifier in the sed expression for "..".

Michael J Gruber (2):
  git submodule: Add test cases for git submodule add
  git submodule: Fix adding of submodules at paths with ./, .. and //

 git-submodule.sh           |   15 ++++++++++--
 t/t7400-submodule-basic.sh |   49 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 3 deletions(-)

^ permalink raw reply

* [PATCHv4 1/2] git submodule: Add test cases for git submodule add
From: Michael J Gruber @ 2009-03-03 15:08 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt, Andrei Thorp, Junio C Hamano
In-Reply-To: <1236092901-28500-1-git-send-email-git@drmicha.warpmail.net>

Add simple test cases for adding and initialising submodules. The
init step is necessary in order to verify the added information.

The second test exposes a known breakage due to './' in the path: git
ls-files simplifies the path but git add does not, which leads to git
init looking for different lines in .gitmodules than git add adds.

The other tests add test cases for '//' and '..' in the path which
currently fail for the same reason.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 t/t7400-submodule-basic.sh |   49 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index b8cb2df..35a0ede 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -47,6 +47,55 @@ test_expect_success 'Prepare submodule testing' '
 	GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
 '
 
+test_expect_success 'Prepare submodule add testing' '
+	submodurl=$(pwd)
+	(
+		mkdir addtest &&
+		cd addtest &&
+		git init
+	)
+'
+
+test_expect_success 'submodule add' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" submod &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with ./ in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with // in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" slashslashsubmod///frotz// &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with /.. in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with ./, /.. and // in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
+		git submodule init
+	)
+'
+
 test_expect_success 'status should fail for unmapped paths' '
 	if git submodule status
 	then
-- 
1.6.2.rc2

^ permalink raw reply related

* [PATCHv4 2/2] git submodule: Fix adding of submodules at paths with ./, .. and //
From: Michael J Gruber @ 2009-03-03 15:08 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt, Andrei Thorp, Junio C Hamano
In-Reply-To: <1236092901-28500-2-git-send-email-git@drmicha.warpmail.net>

Make 'git submodule add' normalize the submodule path in the
same way as 'git ls-files' does, so that 'git submodule init' looks up
the information in .gitmodules with the same key under which 'git
submodule add' stores it.

This fixes 4 known breakages.
---
 git-submodule.sh           |   15 ++++++++++++---
 t/t7400-submodule-basic.sh |    8 ++++----
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 204aab6..0a27232 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -167,9 +167,18 @@ cmd_add()
 	;;
 	esac
 
-	# strip trailing slashes from path
-	path=$(echo "$path" | sed -e 's|/*$||')
-
+	# normalize path:
+	# multiple //; leading ./; /./; /../; trailing /
+	path=$(printf '%s/\n' "$path" |
+		sed -e '
+			s|//*|/|g
+			s|^\(\./\)*||
+			s|/\./|/|g
+			:start
+			s|\([^/]*\)/\.\./||
+			tstart
+			s|/*$||
+		')
 	git ls-files --error-unmatch "$path" > /dev/null 2>&1 &&
 	die "'$path' already exists in the index"
 
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 35a0ede..af690ec 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -64,7 +64,7 @@ test_expect_success 'submodule add' '
 	)
 '
 
-test_expect_failure 'submodule add with ./ in path' '
+test_expect_success 'submodule add with ./ in path' '
 	(
 		cd addtest &&
 		git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
@@ -72,7 +72,7 @@ test_expect_failure 'submodule add with ./ in path' '
 	)
 '
 
-test_expect_failure 'submodule add with // in path' '
+test_expect_success 'submodule add with // in path' '
 	(
 		cd addtest &&
 		git submodule add "$submodurl" slashslashsubmod///frotz// &&
@@ -80,7 +80,7 @@ test_expect_failure 'submodule add with // in path' '
 	)
 '
 
-test_expect_failure 'submodule add with /.. in path' '
+test_expect_success 'submodule add with /.. in path' '
 	(
 		cd addtest &&
 		git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
@@ -88,7 +88,7 @@ test_expect_failure 'submodule add with /.. in path' '
 	)
 '
 
-test_expect_failure 'submodule add with ./, /.. and // in path' '
+test_expect_success 'submodule add with ./, /.. and // in path' '
 	(
 		cd addtest &&
 		git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
-- 
1.6.2.rc2

^ permalink raw reply related

* Re: First round of UGFWIINI results
From: Reece Dunn @ 2009-03-03 15:09 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <alpine.DEB.1.00.0902171745320.6185@intel-tinevez-2-302>

2009/2/17 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
> Dear fans of Git,
>
> a while ago I announced the UGFWIINI contest, a glorious battle of ideas
> how to
>
>        Use Git For What It Is Not Indended

Does using Git to track edits when proofreading a html/text document
(short story, novel, ...) count?

This is similar to the ODF <-> Git entry. Now all that needs to happen
is to replace the ZIP format with a git repository and create a plugin
for an ODF reader that makes git calls when doing the content tracking
checks.

- Reece

^ permalink raw reply

* Re: git log -Sfoo ignores indentation (whitespace?) changes...
From: Jeff King @ 2009-03-03 15:23 UTC (permalink / raw)
  To: "Peter Valdemar Mørch (Lists)"; +Cc: git
In-Reply-To: <49AD3E78.1050706@sneakemail.com>

On Tue, Mar 03, 2009 at 03:28:08PM +0100, "Peter Valdemar Mørch (Lists)" wrote:

> Commits where only the indentation of 'foo' is changed are not shown with 
> "git log -Sfoo". Is there any way to force showing them along with other 
> changes involving foo? (E.g. for python, indentation matters!)
>
> Why doesn't the second commit show up in the following?

Because you misunderstand how "-S" works (but don't worry, it's not your
fault -- the documentation is somewhat misleading). The documentation says:

  -S<string>
    Look for differences that contain the change in <string>.

but what it actually does is find changes where the string was introduced
or removed. So it literally counts the number of occurences before and
after the commit, and the commit is interesting if they are not equal.

> # Create text containing 'line' without whitespace
> $ echo 'line' > text
> $ git add text
> $ git commit -m "first" text
>
> # Here, I add one space of indentation in front of 'line'
> $ echo ' line' > text
> $ git commit -m "second" text

So "line" wasn't actually changed. It just happens to be on a line which
_did_ change.

> I would like to see both "first" and "second" somehow - can I do that?

I don't think there's an easy way to do this right now; you would need
to do "git log -p" and search through the output to get what you want (I
often do this just using the pager's search function).

-Peff

^ permalink raw reply

* Re: [PATCHv4 2/2] git submodule: Fix adding of submodules at paths with ./, .. and //
From: Johannes Sixt @ 2009-03-03 15:28 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: git, Andrei Thorp, Junio C Hamano
In-Reply-To: <1236092901-28500-3-git-send-email-git@drmicha.warpmail.net>

Michael J Gruber schrieb:
> Make 'git submodule add' normalize the submodule path in the
> same way as 'git ls-files' does, so that 'git submodule init' looks up
> the information in .gitmodules with the same key under which 'git
> submodule add' stores it.
> 
> This fixes 4 known breakages.
> ---

OK!

Tested-by: Johannes Sixt <j6t@kdbg.org> (AIX)

but really, I ran only: cd t && make *submodule*

You certainly will sign off this patch?

-- Hannes

^ permalink raw reply

* parallel dev. with email
From: stoecher @ 2009-03-03 15:31 UTC (permalink / raw)
  To: git

Hi,

I am new to git and I am wondering what git commands to use for this szenario: two developers without the possibility of sharing a server communicate their changes via email.

This is how far I have come reading the online docu:
* Each developer can create the diff-info of his commits with
  git format-patch
* and the other developer can incorporate these changes with
  git am

After creating the patches with format-patch one could set a tag:
  git tag -f patchesDone
so next time one wants to create patches, this tag can be used as the starting point:
  git format-patch patchesDone..

But what if in the meantime one has incorporated the other developer's changes with git am? Then these changes will also be among the patches created with format-patch. What will happen, if these patches are sent to the other developer, who does not need his own changes again. Will his own changes be silently ignored by git am? Or how else to effectively coordinate the work of two developers with git via email?

thank you,

Wolfgang
-- 
Computer Bild Tarifsieger! GMX FreeDSL - Telefonanschluss + DSL
für nur 17,95 ¿/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a

^ permalink raw reply

* Re: [PATCH] grep: add --blame so grep can show blame result at the  same time
From: Junio C Hamano @ 2009-03-03 15:33 UTC (permalink / raw)
  To: pi.songs; +Cc: git
In-Reply-To: <1b29507a0903030427y15ad89d7y9f55a945612f0e20@mail.gmail.com>

pi song <pi.songs@gmail.com> writes:

> My god, this is too big. I cannot attach or paste in email. What should I
> do?

For a starter, try removing hunks that record only unwarranted changes,
such as the following.  They are all style regressions.

@@ -517,6 +563,8 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
 				show_name(opt, name);
 				return 1;
 			}
+
+                        
 			/* Hit at this line.  If we haven't shown the
 			 * pre-context lines, we would need to show them.
 			 * When asked to do "count", this still show
@@ -524,7 +572,9 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
 			 * deserves to get that ;-).
 			 */
 			if (opt->pre_context) {
+                            
 				unsigned from;
+
 				if (opt->pre_context < lno)
 					from = lno - opt->pre_context;
 				else
@@ -590,8 +664,10 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
 	 * make it another option?  For now suppress them.
 	 */
 	if (opt->count && count)
+        {
 		printf("%s%c%u\n", name,
 		       opt->null_following_name ? '\0' : ':', count);
+        }
 	return !!last_hit;
 }
 

^ permalink raw reply


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