* Re: [PATCH JGIT 5/5] Treat gitlink tree entries similar to symlink tree entries
From: Shawn O. Pearce @ 2009-08-12 15:32 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: Robin Rosenberg, git
In-Reply-To: <1250089629-22547-1-git-send-email-fonseca@diku.dk>
Jonas Fonseca <fonseca@diku.dk> wrote:
> Adds minimal support for gitlinks, based on the existing code for
> handling symlinks. The goal is to avoid exceptions when reading trees
> with gitlinks.
Applied, but who calls GitlinkTreeEntry ?
> .../jgit/errors/GitlinksNotSupportedException.java | 58 +++++++++++++
> .../src/org/spearce/jgit/lib/ForceModified.java | 4 +
> .../src/org/spearce/jgit/lib/GitlinkTreeEntry.java | 85 ++++++++++++++++++++
> .../src/org/spearce/jgit/lib/TreeVisitor.java | 8 ++
> .../src/org/spearce/jgit/lib/WriteTree.java | 7 ++
> 5 files changed, 162 insertions(+), 0 deletions(-)
> create mode 100644 org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java
> create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
--
Shawn.
^ permalink raw reply
* [PATCH] git-gui: Update russian translation
From: Alex Riesen @ 2009-08-12 15:24 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Dan Zwell, Git Mailing List
In-Reply-To: <20090812144345.GC1033@spearce.org>
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
Shawn O. Pearce, Wed, Aug 12, 2009 16:43:45 +0200:
> Dan Zwell <dzwell@zwell.net> wrote:
> > When there is a large number of new or modified files,
> > "display_all_files" takes a long time, and git-gui appears to
> > hang. This change limits the number of files that are displayed.
> > This limit can be set as gui.maxfilesdisplayed, and is
> > 5000 by default.
> >
> > A warning is shown when the list of files is truncated.
>
> Thanks, applied.
>
And the updated translation.
But now, when I really think about the change, it looks useless.
What has the _number_ of files has to do with the files you actually
have to handle? As the sorting of the file list cannot be changed (and
it wouldn't be a big help anyway), you have no chance to get to your
file if it happens to be past the limit!
Wouldn't a pathname/glob filter in the command-line (or file/path
selection dialog) to limit the scope be more appropriate and useful?
And have the file list reading to happen in background, as gitk does?
po/ru.po | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/po/ru.po b/po/ru.po
index 0ffc4a4..364c074 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -90,12 +90,18 @@ msgstr "Вызов программы поддержки репозитория
#: git-gui.sh:1384
msgid "Commit declined by prepare-commit-msg hook."
-msgstr "Сохранение прервано программой поддержки репозитория prepare-commit-msg"
+msgstr ""
+"Сохранение прервано программой поддержки репозитория prepare-commit-msg"
#: git-gui.sh:1542 lib/browser.tcl:246
msgid "Ready."
msgstr "Готово."
+#: git-gui.sh:1726
+#, tcl-format
+msgid "Displaying only %s of %s files."
+msgstr "Показано %s из %s файлов."
+
#: git-gui.sh:1819
msgid "Unmodified"
msgstr "Не изменено"
@@ -1297,8 +1303,8 @@ msgid ""
msgstr ""
"Невозможно исправить состояние во время операции слияния.\n"
"\n"
-"Текущее слияние не завершено. Невозможно исправить предыдущее "
-"сохраненное состояние, не прерывая эту операцию.\n"
+"Текущее слияние не завершено. Невозможно исправить предыдущее сохраненное "
+"состояние, не прерывая эту операцию.\n"
#: lib/commit.tcl:48
msgid "Error loading commit data for amend:"
@@ -1723,8 +1729,7 @@ msgid ""
msgstr ""
"Невозможно выполнить слияние во время исправления.\n"
"\n"
-"Завершите исправление данного состояния перед выполнением операции "
-"слияния.\n"
+"Завершите исправление данного состояния перед выполнением операции слияния.\n"
#: lib/merge.tcl:27
msgid ""
@@ -1888,8 +1893,8 @@ msgstr ""
#, tcl-format
msgid "File %s seems to have unresolved conflicts, still stage?"
msgstr ""
-"Файл %s кажется содержит необработаные конфликты. "
-"Продолжить подготовку к сохранению?"
+"Файл %s кажется содержит необработаные конфликты. Продолжить подготовку к "
+"сохранению?"
#: lib/mergetool.tcl:60
#, tcl-format
@@ -2213,8 +2218,8 @@ msgid ""
"One or more of the merge tests failed because you have not fetched the "
"necessary commits. Try fetching from %s first."
msgstr ""
-"Некоторые тесты на слияние не прошли, потому что Вы не "
-"получили необходимые состояния. Попытайтесь получить их из %s."
+"Некоторые тесты на слияние не прошли, потому что Вы не получили необходимые "
+"состояния. Попытайтесь получить их из %s."
#: lib/remote_branch_delete.tcl:207
msgid "Please select one or more branches to delete."
@@ -2381,8 +2386,8 @@ msgstr "Выполнение: %s"
#: lib/tools.tcl:149
#, tcl-format
-msgid "Tool completed succesfully: %s"
-msgstr "Программа %s успешно завершилась."
+msgid "Tool completed successfully: %s"
+msgstr "Программа %s завершилась успешно."
#: lib/tools.tcl:151
#, tcl-format
@@ -2538,4 +2543,3 @@ msgstr "Использовать thin pack (для медленных сетев
#: lib/transport.tcl:179
msgid "Include tags"
msgstr "Передать метки"
-
--
1.6.4.140.gc6dfd
^ permalink raw reply related
* Re: [PATCH JGIT 2/5] FileMode: Store bit masks in int constants
From: Shawn O. Pearce @ 2009-08-12 15:22 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: Robin Rosenberg, git
In-Reply-To: <1250089776-22895-1-git-send-email-fonseca@diku.dk>
Jonas Fonseca <fonseca@diku.dk> wrote:
> + public static final int TYPE_MASK = 0170000;
> + public static final int TREE_MASK = 0040000;
> + public static final int SYMLINK_MASK = 0120000;
> + public static final int FILE_MASK = 0100000;
> + public static final int GITLINK_MASK = 0160000;
> + public static final int MISSING_MASK = 0000000;
These last 5 entries aren't masks, they are type codes. I'd rather
they be called FOO_TYPE than FOO_MASK. In particular what is really
troubling is MISSING_MASK, being all 0 it always destroys the input
and then matches everything. :-)
I'm going to amend this name change in here, s/_MASK/_TYPE/ on the
last 5 fields.
--
Shawn.
^ permalink raw reply
* [PATCH JGIT 2/5] FileMode: Store bit masks in int constants
From: Jonas Fonseca @ 2009-08-12 15:09 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
In-Reply-To: <2c6b72b30908120733h4ecb3fccm3a1e80c111c1185c@mail.gmail.com>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
.../src/org/spearce/jgit/lib/FileMode.java | 38 ++++++++++++--------
.../spearce/jgit/treewalk/WorkingTreeIterator.java | 8 ++--
2 files changed, 27 insertions(+), 19 deletions(-)
Resend without mailer errors ...
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java b/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
index cf42f37..a1f82f8 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
@@ -50,21 +50,29 @@
* </p>
*/
public abstract class FileMode {
+
+ public static final int TYPE_MASK = 0170000;
+ public static final int TREE_MASK = 0040000;
+ public static final int SYMLINK_MASK = 0120000;
+ public static final int FILE_MASK = 0100000;
+ public static final int GITLINK_MASK = 0160000;
+ public static final int MISSING_MASK = 0000000;
+
/** Mode indicating an entry is a {@link Tree}. */
@SuppressWarnings("synthetic-access")
- public static final FileMode TREE = new FileMode(0040000,
+ public static final FileMode TREE = new FileMode(TREE_MASK,
Constants.OBJ_TREE) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0040000;
+ return (modeBits & TYPE_MASK) == TREE_MASK;
}
};
/** Mode indicating an entry is a {@link SymlinkTreeEntry}. */
@SuppressWarnings("synthetic-access")
- public static final FileMode SYMLINK = new FileMode(0120000,
+ public static final FileMode SYMLINK = new FileMode(SYMLINK_MASK,
Constants.OBJ_BLOB) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0120000;
+ return (modeBits & TYPE_MASK) == SYMLINK_MASK;
}
};
@@ -73,7 +81,7 @@ public boolean equals(final int modeBits) {
public static final FileMode REGULAR_FILE = new FileMode(0100644,
Constants.OBJ_BLOB) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0100000 && (modeBits & 0111) == 0;
+ return (modeBits & TYPE_MASK) == FILE_MASK && (modeBits & 0111) == 0;
}
};
@@ -82,22 +90,22 @@ public boolean equals(final int modeBits) {
public static final FileMode EXECUTABLE_FILE = new FileMode(0100755,
Constants.OBJ_BLOB) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0100000 && (modeBits & 0111) != 0;
+ return (modeBits & TYPE_MASK) == FILE_MASK && (modeBits & 0111) != 0;
}
};
/** Mode indicating an entry is a submodule commit in another repository. */
@SuppressWarnings("synthetic-access")
- public static final FileMode GITLINK = new FileMode(0160000,
+ public static final FileMode GITLINK = new FileMode(GITLINK_MASK,
Constants.OBJ_COMMIT) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0160000;
+ return (modeBits & TYPE_MASK) == GITLINK_MASK;
}
};
/** Mode indicating an entry is missing during parallel walks. */
@SuppressWarnings("synthetic-access")
- public static final FileMode MISSING = new FileMode(0000000,
+ public static final FileMode MISSING = new FileMode(MISSING_MASK,
Constants.OBJ_BAD) {
public boolean equals(final int modeBits) {
return modeBits == 0;
@@ -112,20 +120,20 @@ public boolean equals(final int modeBits) {
* @return the FileMode instance that represents the given bits.
*/
public static final FileMode fromBits(final int bits) {
- switch (bits & 0170000) {
- case 0000000:
+ switch (bits & TYPE_MASK) {
+ case MISSING_MASK:
if (bits == 0)
return MISSING;
break;
- case 0040000:
+ case TREE_MASK:
return TREE;
- case 0100000:
+ case FILE_MASK:
if ((bits & 0111) != 0)
return EXECUTABLE_FILE;
return REGULAR_FILE;
- case 0120000:
+ case SYMLINK_MASK:
return SYMLINK;
- case 0160000:
+ case GITLINK_MASK:
return GITLINK;
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
index d4291ea..6003736 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
@@ -134,16 +134,16 @@ protected WorkingTreeIterator(final WorkingTreeIterator p) {
public byte[] idBuffer() {
if (contentIdFromPtr == ptr)
return contentId;
- switch (mode & 0170000) {
- case 0100000: /* normal files */
+ switch (mode & FileMode.TYPE_MASK) {
+ case FileMode.FILE_MASK:
contentIdFromPtr = ptr;
return contentId = idBufferBlob(entries[ptr]);
- case 0120000: /* symbolic links */
+ case FileMode.SYMLINK_MASK:
// Java does not support symbolic links, so we should not
// have reached this particular part of the walk code.
//
return zeroid;
- case 0160000: /* gitlink */
+ case FileMode.GITLINK_MASK:
// TODO: Support obtaining current HEAD SHA-1 from nested repository
//
return zeroid;
--
1.6.4.rc3.195.g2b05f
^ permalink raw reply related
* [PATCH JGIT 5/5] Treat gitlink tree entries similar to symlink tree entries
From: Jonas Fonseca @ 2009-08-12 15:07 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
Adds minimal support for gitlinks, based on the existing code for
handling symlinks. The goal is to avoid exceptions when reading trees
with gitlinks.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
.../jgit/errors/GitlinksNotSupportedException.java | 58 +++++++++++++
.../src/org/spearce/jgit/lib/ForceModified.java | 4 +
.../src/org/spearce/jgit/lib/GitlinkTreeEntry.java | 85 ++++++++++++++++++++
.../src/org/spearce/jgit/lib/TreeVisitor.java | 8 ++
.../src/org/spearce/jgit/lib/WriteTree.java | 7 ++
5 files changed, 162 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java
new file mode 100644
index 0000000..8f8883f
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
+ * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
+ *
+ * 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.jgit.errors;
+
+import java.io.IOException;
+
+/**
+ * An exception thrown when a gitlink entry is found and cannot be
+ * handled.
+ */
+public class GitlinksNotSupportedException extends IOException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct a GitlinksNotSupportedException for the specified link
+ *
+ * @param s name of link in tree or workdir
+ */
+ public GitlinksNotSupportedException(final String s) {
+ super(s);
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ForceModified.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ForceModified.java
index 6d38068..9c94e13 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ForceModified.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ForceModified.java
@@ -61,4 +61,8 @@ public void visitSymlink(final SymlinkTreeEntry s) throws IOException {
// Eclipse
// and Pure Java does not know what to do about symbolic links.
}
+
+ public void visitGitlink(GitlinkTreeEntry s) throws IOException {
+ // TODO: handle gitlinks.
+ }
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
new file mode 100644
index 0000000..babbc26
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
+ * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
+ *
+ * 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.jgit.lib;
+
+import java.io.IOException;
+
+/**
+ * A tree entry representing a symbolic link.
+ *
+ * Note. Java cannot really handle these as file system objects.
+ */
+public class GitlinkTreeEntry extends TreeEntry {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct a {@link SymlinkTreeEntry} with the specified name and SHA-1 in
+ * the specified parent
+ *
+ * @param parent
+ * @param id
+ * @param nameUTF8
+ */
+ public GitlinkTreeEntry(final Tree parent, final ObjectId id,
+ final byte[] nameUTF8) {
+ super(parent, id, nameUTF8);
+ }
+
+ public FileMode getMode() {
+ return FileMode.GITLINK;
+ }
+
+ public void accept(final TreeVisitor tv, final int flags)
+ throws IOException {
+ if ((MODIFIED_ONLY & flags) == MODIFIED_ONLY && !isModified()) {
+ return;
+ }
+
+ tv.visitGitlink(this);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuffer r = new StringBuffer();
+ r.append(ObjectId.toString(getId()));
+ r.append(" G ");
+ r.append(getFullName());
+ return r.toString();
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitor.java b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitor.java
index 78a6c22..8293c24 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitor.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitor.java
@@ -77,4 +77,12 @@
* @throws IOException
*/
public void visitSymlink(final SymlinkTreeEntry s) throws IOException;
+
+ /**
+ * Visit to a gitlink.
+ *
+ * @param s Gitlink entry
+ * @throws IOException
+ */
+ public void visitGitlink(final GitlinkTreeEntry s) throws IOException;
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/WriteTree.java b/org.spearce.jgit/src/org/spearce/jgit/lib/WriteTree.java
index 9841678..d6725a9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/WriteTree.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/WriteTree.java
@@ -41,6 +41,7 @@
import java.io.File;
import java.io.IOException;
+import org.spearce.jgit.errors.GitlinksNotSupportedException;
import org.spearce.jgit.errors.SymlinksNotSupportedException;
/**
@@ -78,4 +79,10 @@ public void endVisitTree(final Tree t) throws IOException {
super.endVisitTree(t);
t.setId(ow.writeTree(t));
}
+
+ public void visitGitlink(GitlinkTreeEntry s) throws IOException {
+ if (s.isModified()) {
+ throw new GitlinksNotSupportedException(s.getFullName());
+ }
+ }
}
--
1.6.4.rc3.195.g2b05f
^ permalink raw reply related
* [PATCH JGIT 4/5] Repository: Make listener collections members final
From: Jonas Fonseca @ 2009-08-12 15:06 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
Silences warnings related with using synchronized() on these members.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
.../src/org/spearce/jgit/lib/Repository.java | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 468cf4c..d6be9bf 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -100,8 +100,8 @@
private GitIndex index;
- private List<RepositoryListener> listeners = new Vector<RepositoryListener>(); // thread safe
- static private List<RepositoryListener> allListeners = new Vector<RepositoryListener>(); // thread safe
+ private final List<RepositoryListener> listeners = new Vector<RepositoryListener>(); // thread safe
+ static private final List<RepositoryListener> allListeners = new Vector<RepositoryListener>(); // thread safe
/**
* Construct a representation of a Git repository.
--
1.6.4.rc3.195.g2b05f
^ permalink raw reply related
* [PATCH JGIT 3/5] Introduce InvalidObjectIdException to reduce code duplicated
From: Jonas Fonseca @ 2009-08-12 15:06 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
Collects error handling code related to parsing of object id's in one
place.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
.../jgit/errors/InvalidObjectIdException.java | 69 ++++++++++++++++++++
.../org/spearce/jgit/lib/AbbreviatedObjectId.java | 10 +--
.../src/org/spearce/jgit/lib/MutableObjectId.java | 12 +---
.../src/org/spearce/jgit/lib/ObjectId.java | 10 +--
4 files changed, 75 insertions(+), 26 deletions(-)
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/errors/InvalidObjectIdException.java
diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/InvalidObjectIdException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/InvalidObjectIdException.java
new file mode 100644
index 0000000..5d50884
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/InvalidObjectIdException.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
+ * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
+ * Copyright (C) 2009, Jonas Fonseca <fonseca@diku.dk>
+ *
+ * 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.jgit.errors;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Thrown when an invalid object id is passed in as an argument.
+ */
+public class InvalidObjectIdException extends IllegalArgumentException {
+
+ /**
+ * Create exception with bytes of the invalid object id.
+ *
+ * @param bytes containing the invalid id.
+ * @param offset in the byte array where the error occured.
+ * @param length of the sequence of invalid bytes.
+ */
+ public InvalidObjectIdException(byte[] bytes, int offset, int length) {
+ super("Invalid id" + asAscii(bytes, offset, length));
+ }
+
+ private static String asAscii(byte[] bytes, int offset, int length) {
+ try {
+ return ": " + new String(bytes, offset, length, "US-ASCII");
+ } catch (UnsupportedEncodingException e2) {
+ return "";
+ } catch (StringIndexOutOfBoundsException e2) {
+ return "";
+ }
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AbbreviatedObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AbbreviatedObjectId.java
index 1706e88..6ad2ea1 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AbbreviatedObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AbbreviatedObjectId.java
@@ -37,8 +37,7 @@
package org.spearce.jgit.lib;
-import java.io.UnsupportedEncodingException;
-
+import org.spearce.jgit.errors.InvalidObjectIdException;
import org.spearce.jgit.util.NB;
import org.spearce.jgit.util.RawParseUtils;
@@ -97,12 +96,7 @@ private static final AbbreviatedObjectId fromHexString(final byte[] bs,
final int e = hexUInt32(bs, ptr + 32, end);
return new AbbreviatedObjectId(end - ptr, a, b, c, d, e);
} catch (ArrayIndexOutOfBoundsException e1) {
- try {
- final String str = new String(bs, ptr, end - ptr, "US-ASCII");
- throw new IllegalArgumentException("Invalid id: " + str);
- } catch (UnsupportedEncodingException e2) {
- throw new IllegalArgumentException("Invalid id");
- }
+ throw new InvalidObjectIdException(bs, ptr, end - ptr);
}
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java
index 805f328..9e25908 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/MutableObjectId.java
@@ -37,8 +37,7 @@
package org.spearce.jgit.lib;
-import java.io.UnsupportedEncodingException;
-
+import org.spearce.jgit.errors.InvalidObjectIdException;
import org.spearce.jgit.util.NB;
import org.spearce.jgit.util.RawParseUtils;
@@ -166,14 +165,7 @@ private void fromHexString(final byte[] bs, int p) {
w4 = RawParseUtils.parseHexInt32(bs, p + 24);
w5 = RawParseUtils.parseHexInt32(bs, p + 32);
} catch (ArrayIndexOutOfBoundsException e1) {
- try {
- final String str = new String(bs, p, STR_LEN, "US-ASCII");
- throw new IllegalArgumentException("Invalid id: " + str);
- } catch (UnsupportedEncodingException e2) {
- throw new IllegalArgumentException("Invalid id");
- } catch (StringIndexOutOfBoundsException e2) {
- throw new IllegalArgumentException("Invalid id");
- }
+ throw new InvalidObjectIdException(bs, p, STR_LEN);
}
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
index cdd523f..310d6e0 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
@@ -38,8 +38,7 @@
package org.spearce.jgit.lib;
-import java.io.UnsupportedEncodingException;
-
+import org.spearce.jgit.errors.InvalidObjectIdException;
import org.spearce.jgit.util.NB;
import org.spearce.jgit.util.RawParseUtils;
@@ -230,12 +229,7 @@ private static final ObjectId fromHexString(final byte[] bs, int p) {
final int e = RawParseUtils.parseHexInt32(bs, p + 32);
return new ObjectId(a, b, c, d, e);
} catch (ArrayIndexOutOfBoundsException e1) {
- try {
- final String str = new String(bs, p, STR_LEN, "US-ASCII");
- throw new IllegalArgumentException("Invalid id: " + str);
- } catch (UnsupportedEncodingException e2) {
- throw new IllegalArgumentException("Invalid id");
- }
+ throw new InvalidObjectIdException(bs, p, STR_LEN);
}
}
--
1.6.4.rc3.195.g2b05f
^ permalink raw reply related
* Re: git gc expanding packed data?
From: Hin-Tak Leung @ 2009-08-12 14:45 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: git
In-Reply-To: <alpine.LFD.2.00.0908111718490.10633@xanadu.home>
On Tue, Aug 11, 2009 at 10:33 PM, Nicolas Pitre<nico@cam.org> wrote:
<snipped>
> From git v1.6.3 the --aggressive switch makes for 'git repack' to be
> called with --window=250 --depth=250, meaning the equivalent of:
>
> git repack -a -d -f --window=250 --depth=250
>
> Do you still get a huge pack with the above?
>
>> I guess --aggressive doesn't always save space...
>
> If so that is (and was) a bug.
I tried 'git repack -a -d -f --window=250 --depth=250' with 1.6.2.5
(fc11.x86_64) and it took half a day, swallowed up all the memory -
3GB virtual & 1.3GB resident - and finally the kernel oom killer
killed it at a last message of (601460/957910). Left no temp files.
Would git 1.6.3 use less memory? :-(
Hin-Tak
^ permalink raw reply
* Re: [PATCH] Limit git-gui to display a maximum number of files
From: Shawn O. Pearce @ 2009-08-12 14:43 UTC (permalink / raw)
To: Dan Zwell; +Cc: Git Mailing List, raa.lkml
In-Reply-To: <4A81BD58.8070300@zwell.net>
Dan Zwell <dzwell@zwell.net> wrote:
> When there is a large number of new or modified files,
> "display_all_files" takes a long time, and git-gui appears to
> hang. This change limits the number of files that are displayed.
> This limit can be set as gui.maxfilesdisplayed, and is
> 5000 by default.
>
> A warning is shown when the list of files is truncated.
Thanks, applied.
--
Shawn.
^ permalink raw reply
* [PATCH JGIT 2/5] FileMode: Store bit masks in int constants
From: Jonas Fonseca @ 2009-08-12 14:33 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
.../src/org/spearce/jgit/lib/FileMode.java | 38 ++++++++++++--------
.../spearce/jgit/treewalk/WorkingTreeIterator.java | 8 ++--
2 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
b/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
index cf42f37..a1f82f8 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
@@ -50,21 +50,29 @@
* </p>
*/
public abstract class FileMode {
+
+ public static final int TYPE_MASK = 0170000;
+ public static final int TREE_MASK = 0040000;
+ public static final int SYMLINK_MASK = 0120000;
+ public static final int FILE_MASK = 0100000;
+ public static final int GITLINK_MASK = 0160000;
+ public static final int MISSING_MASK = 0000000;
+
/** Mode indicating an entry is a {@link Tree}. */
@SuppressWarnings("synthetic-access")
- public static final FileMode TREE = new FileMode(0040000,
+ public static final FileMode TREE = new FileMode(TREE_MASK,
Constants.OBJ_TREE) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0040000;
+ return (modeBits & TYPE_MASK) == TREE_MASK;
}
};
/** Mode indicating an entry is a {@link SymlinkTreeEntry}. */
@SuppressWarnings("synthetic-access")
- public static final FileMode SYMLINK = new FileMode(0120000,
+ public static final FileMode SYMLINK = new FileMode(SYMLINK_MASK,
Constants.OBJ_BLOB) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0120000;
+ return (modeBits & TYPE_MASK) == SYMLINK_MASK;
}
};
@@ -73,7 +81,7 @@ public boolean equals(final int modeBits) {
public static final FileMode REGULAR_FILE = new FileMode(0100644,
Constants.OBJ_BLOB) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0100000 && (modeBits & 0111) == 0;
+ return (modeBits & TYPE_MASK) == FILE_MASK && (modeBits & 0111) == 0;
}
};
@@ -82,22 +90,22 @@ public boolean equals(final int modeBits) {
public static final FileMode EXECUTABLE_FILE = new FileMode(0100755,
Constants.OBJ_BLOB) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0100000 && (modeBits & 0111) != 0;
+ return (modeBits & TYPE_MASK) == FILE_MASK && (modeBits & 0111) != 0;
}
};
/** Mode indicating an entry is a submodule commit in another repository. */
@SuppressWarnings("synthetic-access")
- public static final FileMode GITLINK = new FileMode(0160000,
+ public static final FileMode GITLINK = new FileMode(GITLINK_MASK,
Constants.OBJ_COMMIT) {
public boolean equals(final int modeBits) {
- return (modeBits & 0170000) == 0160000;
+ return (modeBits & TYPE_MASK) == GITLINK_MASK;
}
};
/** Mode indicating an entry is missing during parallel walks. */
@SuppressWarnings("synthetic-access")
- public static final FileMode MISSING = new FileMode(0000000,
+ public static final FileMode MISSING = new FileMode(MISSING_MASK,
Constants.OBJ_BAD) {
public boolean equals(final int modeBits) {
return modeBits == 0;
@@ -112,20 +120,20 @@ public boolean equals(final int modeBits) {
* @return the FileMode instance that represents the given bits.
*/
public static final FileMode fromBits(final int bits) {
- switch (bits & 0170000) {
- case 0000000:
+ switch (bits & TYPE_MASK) {
+ case MISSING_MASK:
if (bits == 0)
return MISSING;
break;
- case 0040000:
+ case TREE_MASK:
return TREE;
- case 0100000:
+ case FILE_MASK:
if ((bits & 0111) != 0)
return EXECUTABLE_FILE;
return REGULAR_FILE;
- case 0120000:
+ case SYMLINK_MASK:
return SYMLINK;
- case 0160000:
+ case GITLINK_MASK:
return GITLINK;
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
index d4291ea..6003736 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
@@ -134,16 +134,16 @@ protected WorkingTreeIterator(final
WorkingTreeIterator p) {
public byte[] idBuffer() {
if (contentIdFromPtr == ptr)
return contentId;
- switch (mode & 0170000) {
- case 0100000: /* normal files */
+ switch (mode & FileMode.TYPE_MASK) {
+ case FileMode.FILE_MASK:
contentIdFromPtr = ptr;
return contentId = idBufferBlob(entries[ptr]);
- case 0120000: /* symbolic links */
+ case FileMode.SYMLINK_MASK:
// Java does not support symbolic links, so we should not
// have reached this particular part of the walk code.
//
return zeroid;
- case 0160000: /* gitlink */
+ case FileMode.GITLINK_MASK:
// TODO: Support obtaining current HEAD SHA-1 from nested repository
//
return zeroid;
--
1.6.4.rc3.195.g2b05f
^ permalink raw reply related
* [PATCH JGIT 1/5] TODO: Update and retitle to "JGit Wishlist"
From: Jonas Fonseca @ 2009-08-12 14:33 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
TODO | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/TODO b/TODO
index 5f35b25..c4ce95e 100644
--- a/TODO
+++ b/TODO
@@ -1,15 +1,9 @@
-= Eclipse Plugin Wishlist =
+= JGit Wishlist =
-Now that we have some basic features in the Eclipse plugin, we need
-to focus on making it usable by average users doing daily tasks.
+Below are some of the areas that needs work. Also take a look at JGit
+related issues in the EGit project:
-== Create Branch ==
-
-Create a new branch from any revision specification.
-
-== Delete Branch ==
-
-Delete a branch.
+ - http://code.google.com/p/egit/issues/list?q=label:Component-JGit
== Switch Branch ==
--
1.6.4.rc3.195.g2b05f
^ permalink raw reply related
* Re: [JGIT PATCH 1/1] Fix for Repository.stripWorkDir when using partial paths
From: Shawn O. Pearce @ 2009-08-12 14:29 UTC (permalink / raw)
To: Adam W. Hawks; +Cc: git
In-Reply-To: <4A821167.6030107@writeme.com>
"Adam W. Hawks" <awhawks@writeme.com> wrote:
> When you call stripWorkDir with a relative path
> you can get a string out of bounds error.
>
> This change fixes that problem by using the absolute paths
> of the file instead of its relative name.
Except it made the existing test suite fail, badly. I'm counting
7 errors and 28 test failures as a result of applying this patch.
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
> index 468cf4c..a68817b 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
> @@ -1036,7 +1036,7 @@ public static boolean isValidRefName(final String refName) {
> * @return normalized repository relative path
> */
> public static String stripWorkDir(File wd, File f) {
> - String relName = f.getPath().substring(wd.getPath().length() + 1);
> + String relName = f.getAbsolutePath().substring(wd.getPath().length() + 1);
> relName = relName.replace(File.separatorChar, '/');
> return relName;
> }
--
Shawn.
^ permalink raw reply
* Re: [EGIT PATCH] Provide a more JavaBeans-style 'getName' accessor for the id Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
From: Shawn O. Pearce @ 2009-08-12 14:20 UTC (permalink / raw)
To: Alex Blewitt; +Cc: robin.rosenberg@dewire.com, git@vger.kernel.org
In-Reply-To: <8ACC6C83-75FD-477C-9083-96CA426FC069@gmail.com>
Alex Blewitt <alex.blewitt@gmail.com> wrote:
> On 10 Aug 2009, at 21:59, "Shawn O." <spearce@spearce.org> wrote:
>>
>>>> ./org/spearce/jgit/revwalk/RevTag.java:206: getName() in
>>>> org.spearce.jgit.revwalk.RevTag cannot override getName() in
>>>> org.spearce.jgit.lib.AnyObjectId; overridden method is final
>>
>> I can't apply this patch because getName() on RevTag is already
>> defined with a different meaning. :-(
>
> That sounds dangerous. We now have a .name() and a .getName() with
> different semantics. Can we not change the RevTag method name to
> something else so that we dont have an inconsistency?
Good point. We didn't think that RevTag.getName method through
very well. Rename it to getTagName() ?
--
Shawn.
^ permalink raw reply
* Re: How do gmail users try out patches from this list?
From: Nguyen Thai Ngoc Duy @ 2009-08-12 13:43 UTC (permalink / raw)
To: Michael J Gruber; +Cc: Wesley J. Landaker, Nicolas Sebrecht, skillzero, git
In-Reply-To: <4A827BF3.8080208@drmicha.warpmail.net>
On 8/12/09, Michael J Gruber <git@drmicha.warpmail.net> wrote:
> I guess for them (webmail users) it would be better if we attached
> patches, but we don't do that here. In any case, our list is mirrored on
> gmane, and you can use the interface there. For example, you get the
> first message in this thread using the gmane id or the message id like this:
>
> http://article.gmane.org/gmane.comp.version-control.git/125591
> http://mid.gmane.org/2729632a0908111343v73fa475fqb6353dcf2f718101@mail.gmail.com
>
> If you add /raw to those URLs you get the original message so that you
> can happily wget/curl/browse and save away.
even better http://download.gmane.org/gmane.comp.version-control.git/N/M
[1] (where N and M is the gmane message ID range) gives you mbox
format of a series of consecutive messages.
[1] http://gmane.org/export.php
--
Duy
^ permalink raw reply
* Re: [PATCH] Fix typos in git-remote.txt and git-symbolic-ref.txt
From: Thomas Rast @ 2009-08-12 13:40 UTC (permalink / raw)
To: Wesley J. Landaker; +Cc: Štěpán Němec, git
In-Reply-To: <200908111826.12338.wjl@icecavern.net>
Wesley J. Landaker wrote:
> On Tuesday 11 August 2009 01:09:32 Thomas Rast wrote:
> > instances of `--
[...]
> Obviously we want consistency, but--as this sentence shows--there is a
> difference between an em-dash and a command-line option like --version.
Note the backtick. This is solely about `--options` vs. `\--options`,
and I highly doubt anyone would want their em-dashes to be typeset in
fixed-width font (that's what the backticks do).
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* [PATCH] Re: [TRIVIAL] Documentation: merge: one <remote> is required
From: Nicolas Sebrecht @ 2009-08-12 13:29 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Junio C Hamano, Paul Bolle, Nicolas Sebrecht, git
In-Reply-To: <m31vnhpc5v.fsf@localhost.localdomain>
The 12/08/09, Jakub Narebski wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> > After you brought up this "one or more", I re-read the docs your patches
> > touched, thinking that the author might have meant 'zero or more of A'
> > with these '<A>...' notation.
> >
> > And I realized that they made perfect sense.
This was my initial thought but...
> I would have thought that it makes more sense to have
>
> <something>...
>
> for one or more, and
>
> [<something>... ]
>
> for zero or more (optional one or more).
...their sense is what Posix states:
Ellipses ( "..." ) are used to denote that one or more occurrences of an
operand are allowed. When an option or an operand followed by ellipses
is enclosed in brackets, zero or more options or operands can be
specified. The form:
utility_name [-g option_argument]...[operand...]
http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_01
(& 12.1.9)
--
Nicolas Sebrecht
^ permalink raw reply
* Re: How do gmail users try out patches from this list?
From: Alex Riesen @ 2009-08-12 12:51 UTC (permalink / raw)
To: skillzero; +Cc: git
In-Reply-To: <2729632a0908111343v73fa475fqb6353dcf2f718101@mail.gmail.com>
On Tue, Aug 11, 2009 at 22:43, <skillzero@gmail.com> wrote:
> Sorry if this is dumb question, but I didn't see any good info in my searches.
>
> How do gmail users normally apply patches that come through the list?
> Do you just manually copy and paste the email to patch files and use
> git apply? Do you use a tool to export to mbox files and use git am?
>
> I've been just doing it manually via copy and paste, but it's kinda tedious.
"Show original", save the page into a file (it's text/plain), remove
the first line
of spaces, and do "git am" on the file. Works every time.
^ permalink raw reply
* Re: git index: how does it work?
From: Shaun Cutts @ 2009-08-12 11:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v7hxi9m4k.fsf@alter.siamese.dyndns.org>
Junio,
Your advice was very helpful.
Digging in, however, I find I still am in the dark on one point: how
does the index track renamed files, and how to query it for
information about them?
For instance, if I add a 5th step to the sequence:
5) git mv foo.c bar.c
Then I am told by "git status" that the file is renamed, but I can't
seem to elict this info using "git ls-files". Under some circumstances
even "git status" lists a new and deleted file after a rename.
Are renames being tracked by the index, and is there a more basic
interface than "status" to query about them?
Thanks for any help,
--- Shaun
On Aug 5, 2009, at 8:00 PM, Junio C Hamano wrote:
> Shaun Cutts <shaun@cuttshome.net> writes:
>
>> I am wondering if someone could explain and/or point me to an
>> explanation of how
>> the git index works.
>>
>> For instance, suppose I have a tracked file: "foo.c"
>>
>> 1) [I modify "foo.c"]
>> 2) git add foo.c
>> 3) [modify again]
>> 4) git commit -m "blah blah"
>>
>> Since I don't include the "-a" switch, the version I added on step
>> 2 is
>> committed. But how does the index keep track of these changes? Does
>> the index
>> file actually contain the hunks of "foo.c" that have been modified?
>> Or is there
>> a "temporary" blob created, which the index points to?
>
> Step 2 hashes foo.c and creates a blob object and registers it to the
> index. Step 4 writes out the index as a tree and makes a commit out
> of
> it.
>
> Running this sequence might be instructive.
>
> 1$ edit foo.c
> 2$ git add foo.c
> 2a$ git ls-files -s foo.c
> 2b$ git diff foo.c
> 2c$ git diff --cached foo.c
> 3$ edit foo.c
> 3a$ git ls-files -s foo.c
> 3b$ git diff foo.c
> 3c$ git diff --cached foo.c
> 4$ git commit -m 'half-edit of foo.c'
> 4a$ git ls-files -s foo.c
> 4b$ git ls-tree HEAD foo.c
> 4c$ git diff foo.c
> 4d$ git diff --cached foo.c
>
> - 2a shows the actual blob object that was created out of foo.c in
> step 2.
>
> - 2b shows the difference between that blob (now in the index) and
> foo.c,
> which should be empty.
>
> - 2c shows the difference between the HEAD commit and the index, which
> should show your edit in step 1.
>
> - 3a shows the blob in the index; you haven't added, so it should show
> the same as 2a.
>
> - 3b shows the difference between the index and foo.c, which should
> show
> the edit in step 3.
>
> - 3c shows the difference between the HEAD commit and the index, which
> should show your edit in step 1.
>
> - 4a shows the blob in the index; you haven't added, so it should show
> the same as 2a.
>
> - 4b shows the blob in the committed tree and the blob object should
> be
> identical to 2a.
>
> - 4c shows the difference between the index and foo.c, which should
> show
> the edit in step 3.
>
> - 4d shows the difference between the HEAD commit and the index, which
> should now be empty.
>
^ permalink raw reply
* Re: [PATCH] Re: [TRIVIAL] Documentation: merge: one <remote> is required
From: Paul Bolle @ 2009-08-12 10:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Nicolas Sebrecht, git
In-Reply-To: <7vy6ppbvdf.fsf@alter.siamese.dyndns.org>
On Tue, 2009-08-11 at 19:48 -0700, Junio C Hamano wrote:
> Paul Bolle <pebolle@tiscali.nl> writes:
> > No, since "<remote>..." means one or more instances of the "<remote>"
> > option.
>
> Does it really?
>
> After you brought up this "one or more", I re-read the docs your patches
> touched, thinking that the author might have meant 'zero or more of A'
> with these '<A>...' notation.
>
> And I realized that they made perfect sense.
>
> In general, you can write:
>
> <command> ...
>
> and read this as "The <command> can be followed by nothing or something
> (zero or more) of unspecified kind". If <command> takes only one type of
> zero or more things, you can _clarify the ellipses_ by prefixing them with
> what kind of "stuff" you are talking about:
>
> <command> <remote>...
>
> and read this as "The <command> can be followed by nothing or something
> (zero or more) of <remote>s".
>
> On the other hand, you can also say (note that the ellipses stand on their
> own and are not associated with <remote>):
>
> <command> <remote> ...
>
> and read this as "It takes one <remote> followed by nothing or something
> (zero or more) of unspecified kind".
It is (now) clear to me that in these two documents the author(s) meant
"zero or more". Still, I find the "one or more" meaning more obvious.
The (GNU) manpages of "cp", "mv", "rm", and "ls" use the "one or more"
meaning. (Note that the explanation quoted above can easily be rewritten
with for "one or more" meaning and still make sense.)
Anyway, I now see that "zero or more" is used quite a lot in git's
manpages. But, that meaning doesn't fit so well with the
"[<command>...]" syntax that is also used a lot in these manpages. (I
find "optionally one or more of <command>" more obvious as otherwise
"<command>..." and "[<command>...]" are basically identical.)
Confusingly, as far as I can see, the manpages of the following commands
seem to use the "one or more" meaning:
git merge-base
git mv
git name-rev
git rm
git send-email
git tag -d
git tag -v
git verify-tag
("git mv" uses both meanings in its synopsis. The two "git tag"
invocations seem to do nothing with zero arguments and do not return an
error.)
If the above commands really use the "one or more" meaning, that would
mean both versions are used in the documentation. I'd say it would be
better to stick to one meaning throughout the manpages.
Paul Bolle
^ permalink raw reply
* Re: [PATCH] Re: [TRIVIAL] Documentation: merge: one <remote> is required
From: Jakub Narebski @ 2009-08-12 10:19 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Paul Bolle, Nicolas Sebrecht, git
In-Reply-To: <7vy6ppbvdf.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> Paul Bolle <pebolle@tiscali.nl> writes:
>
>>> Shoudn't be
>>>
>>> [-m <msg>] <remote> [<remote>...]
>>
>> No, since "<remote>..." means one or more instances of the "<remote>"
>> option.
>
> Does it really?
>
> After you brought up this "one or more", I re-read the docs your patches
> touched, thinking that the author might have meant 'zero or more of A'
> with these '<A>...' notation.
>
> And I realized that they made perfect sense.
>
> In general, you can write:
>
> <command> ...
>
> and read this as "The <command> can be followed by nothing or something
> (zero or more) of unspecified kind". If <command> takes only one type of
> zero or more things, you can _clarify the ellipses_ by prefixing them with
> what kind of "stuff" you are talking about:
>
> <command> <remote>...
>
> and read this as "The <command> can be followed by nothing or something
> (zero or more) of <remote>s".
I would have thought that it makes more sense to have
<something>...
for one or more, and
[<something>... ]
for zero or more (optional one or more).
Documentation/DocumentationLanguage, anyone? ;-))))
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply
* Re: [RFC PATCH v3 8/8] --sparse for porcelains
From: Nguyen Thai Ngoc Duy @ 2009-08-12 10:01 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Johannes Schindelin
In-Reply-To: <7v3a7xa6e5.fsf@alter.siamese.dyndns.org>
2009/8/12 Junio C Hamano <gitster@pobox.com>:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> @@ -594,6 +596,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
>> OPT_BOOLEAN('m', "merge", &opts.merge, "merge"),
>> OPT_STRING(0, "conflict", &conflict_style, "style",
>> "conflict style (merge or diff3)"),
>> + OPT_SET_INT(0, "sparse", &opts.apply_sparse,
>> + "apply sparse checkout filter", 1),
>
> Shouldn't this be BOOLEAN not INT, i.e. "--[no-]sparse"? That way, you
> could enable it by simply the presense of $GIT_DIR/info/sparse.
This patch was written carelessly. I wanted to have something to test.
If you agree on option name "--sparse" then yes BOOLEAN is better.
> It could also require core.sparseworktree configuration set to true if we
> are really paranoid, but without the actual sparse specification file
> flipping that configuration to true would not be useful anyway, so in
> practice, giving --sparse-work-tree option to these Porcelain commands
> would be no-op, but --no-sparse-work-tree option would be useful to
> ignore $GIT_DIR/info/sparse and populate the work tree fully.
>
> Or am I missing something?
Sounds good (and --sparse-work-tree is apparently better than
--sparse). So let's enable it by default, add --no-sparse-work-tree to
disable it and wait until some one complains, then we'll add
core.sparseworktree. I think core.sparseworktree can also be used to
specify what spec file to be used instead of the default
.git/info/sparse, if users like to switch among some well-defined spec
files.
--
Duy
^ permalink raw reply
* Re: RFC for 1.7: Do not checkout -b master origin/master on clone
From: Eric Wong @ 2009-08-12 9:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Michael J Gruber, Git Mailing List
In-Reply-To: <7v8whpda2l.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
> > - Why does git svn set up a local branch with an svn upstream which is
> > determined by latest svn commit at the time of the first git svn fetch?
>
> I do not have comments on design decisions in git-svn, other than trusting
> that Eric would exercise good design tastes to make things coherent with
> the git native workflow when the consistency makes sense.
Using 'trunk' (if available) as the master on new fetches does probably
make more sense based on the complaints I've gotten. At the time,
several projects I cared about did almost all their work in branches and
trunk would go untouched for months.... These days most projects I care
about are already using git :)
--
Eric Wong
^ permalink raw reply
* Re: [RFC PATCH v3 8/8] --sparse for porcelains
From: Nguyen Thai Ngoc Duy @ 2009-08-12 9:53 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Johannes Schindelin, Junio C Hamano
In-Reply-To: <4A826FD4.5080201@viscovery.net>
2009/8/12 Johannes Sixt <j.sixt@viscovery.net>:
> BTW, the name .git/info/sparse is perhaps a bit too technical in the sense
> that only git developers know that this feature runs under the name
> "sparse checkout". Perhaps it should be named
>
> .git/info/indexonly
> .git/info/nocheckout
>
> or so.
I did not like the name "sparse" either. Another option is
.git/info/assume-unchanged.
--
Duy
^ permalink raw reply
* Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh
From: Eric Wong @ 2009-08-12 9:49 UTC (permalink / raw)
To: Adam Brewster; +Cc: git
In-Reply-To: <1250046867-13655-1-git-send-email-adambrewster@gmail.com>
Adam Brewster <adambrewster@gmail.com> wrote:
> Eric,
>
> Any thoughts on the other patch?
>
> Am I close or is there a better way to go about this?
>
> I didn't really know what to do with .git/svn/*. The easy answer is
>
> mkdir -p $GIT_DIR/svn/refs/remotes &&
> mv $GIT_DIR/svn/* $GIT_DIR/svn/refs/remotes
That should be acceptable. I don't think it's worth the trouble to
force the majority of existing repos to move over to the new layout
(in case the user wants to switch between multiple versions of git).
> From the comments in the Migration module, it seems like that's frowned
> upon, so I came up with looking for .rev_map (or .rev_db) in both
> locations (.git/svn/git-svn and .git/svn/refs/remotes/svn) and letting
> it stay in whichever location it already exists. (The next email has a
> slightly improved version of the patch.)
>
> This solution is particularly inelegant in it's handling of
> unhandled.log, but as far as I know that file is unused.
I'd still rather avoid creating unhandled.log in two places and
having an unused set of directories.
I think the following change on top of yours would make most
sense:
diff --git a/git-svn.perl b/git-svn.perl
index cafd7fe..1117f28 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3325,8 +3325,18 @@ sub _new {
}
$_[1] = $repo_id;
my $dir = "$ENV{GIT_DIR}/svn/$ref_id";
+
+ # Older repos imported by us used $GIT_DIR/svn/foo instead of
+ # $GIT_DIR/svn/refs/remotes/foo when tracking refs/remotes/foo
+ if ($ref_id =~ m{^refs/remotes/(.*)}) {
+ my $old_dir = "$ENV{GIT_DIR}/svn/$1";
+ if (-d $old_dir && ! -d $dir) {
+ $dir = $old_dir;
+ }
+ }
+
$_[3] = $path = '' unless (defined $path);
- mkpath(["$ENV{GIT_DIR}/svn/$ref_id"]);
+ mkpath([$dir]);
bless {
ref_id => $ref_id, dir => $dir, index => "$dir/index",
path => $path, config => "$ENV{GIT_DIR}/svn/config",
@@ -3355,16 +3365,7 @@ sub rev_db_path {
sub map_path {
my ($self, $uuid) = @_;
$uuid ||= $self->ra_uuid;
- my $map_path = "$self->{map_root}.$uuid";
- return $map_path if ( -f $map_path );
-
- my $db_path = $map_path;
- $db_path =~ s/\.rev_map/.rev_db/;
- return $map_path if ( -f $db_path );
-
- return $1 if ($map_path =~ m(refs/remotes/(.*)) && -f $1);
- return $1 if ($db_path =~ m(refs/remotes/(.*)) && -f $1);
- return $map_path;
+ "$self->{map_root}.$uuid";
}
sub uri_encode {
----
The map_path() changes you originally made didn't work, either, since
the -f $1 never took GIT_DIR or GIT_DIR/svn into account.
> There's also the problem of what to do if someone has a ref called
> ref/remotes/refs/remotes/..., but that seems unlikely enough to not
> cause concern.
I concur. There's always cases where things will be ambiguous
and cases where a user is just asking for trouble :)
I think the below is a good enough test case to for compatibility
against existing repos. Let me know what you think, thanks!
diff --git a/t/t9144-git-svn-old-rev_map.sh b/t/t9144-git-svn-old-rev_map.sh
new file mode 100755
index 0000000..7600a35
--- /dev/null
+++ b/t/t9144-git-svn-old-rev_map.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Eric Wong
+
+test_description='git svn old rev_map preservd'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup test repository with old layout' '
+ mkdir i &&
+ (cd i && > a) &&
+ svn_cmd import -m- i "$svnrepo" &&
+ git svn init "$svnrepo" &&
+ git svn fetch &&
+ test -d .git/svn/refs/remotes/git-svn/ &&
+ ! test -e .git/svn/git-svn/ &&
+ mv .git/svn/refs/remotes/git-svn .git/svn/ &&
+ rm -r .git/svn/refs
+'
+
+test_expect_success 'old layout continues to work' '
+ svn_cmd import -m- i "$svnrepo/b" &&
+ git svn rebase &&
+ echo a >> b/a &&
+ git add b/a &&
+ git commit -m- -a &&
+ git svn dcommit &&
+ ! test -d .git/svn/refs/ &&
+ test -e .git/svn/git-svn/
+'
+
+test_done
--
Eric Wong
^ permalink raw reply related
* Re: [PATCH 5/8] Add a config option for remotes to specify a foreign vcs
From: Jakub Narebski @ 2009-08-12 9:33 UTC (permalink / raw)
To: Jeff King
Cc: Johannes Schindelin, Bert Wesarg, Junio C Hamano, Daniel Barkalow,
git, Brian Gernhardt
In-Reply-To: <20090812074521.GD15152@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> 1. Is there some other syntax that _doesn't_ have this breakage
> but that similarly helps the "vast majority of Git users".
Well, proposed possible syntax was:
1. <vcs>:<repository location>
e.g.:
svn:http://svn.example.com/project
but
host:path/to/repo
2. <vcs>::<repository location>
e.g.
svn::http://svn.example.com/project
3. <vcs>+<repository location>
e.g.
svn+http://svn.example.com/project
but
http+svn://svn.example.com/project
svn+path/to/repo
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox