* Re: git-svn not working when parent of cloned dir requires auth
From: Junio C Hamano @ 2008-12-08 21:30 UTC (permalink / raw)
To: D. Stuart Freeman; +Cc: git, Eric Wong
In-Reply-To: <20081208205418.GA16418@cetel-004-xx6.admin.gatech.edu>
"D. Stuart Freeman" <stuart.freeman@et.gatech.edu> writes:
> I'm trying to
> 'git svn clone https://mware.ucdavis.edu/svn/ucd-sakai/gradebook-gwt -s'
> that repo is setup to allow anonymous reading of that directory tree, but
> git-svn prompts me for a password. I think git-svn is traversing up the
> directory tree and encountering a directory that needs authn, can I prevent
> it from doing that?
That sounds suspiciously similar to what I observed long time ago:
http://thread.gmane.org/gmane.comp.version-control.git/46361/focus=46558
And $gmane/47151 in the thread, aka dc43166 (git-svn: don't minimize-url
when doing an init that tracks multiple paths, 2007-05-19), supposed to
have fixed it.
Hmm... Eric?
^ permalink raw reply
* [EGIT PATCH] Cache values of symbolic refs in RefDatabase
From: Robin Rosenberg @ 2008-12-08 21:48 UTC (permalink / raw)
To: spearce; +Cc: git, Robin Rosenberg
This way we avoid reading refs if the timestamp has not changed. This
reduced the number of opens for reading symbolic refs like HEAD.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/jgit/lib/RefDatabase.java | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
index 494aecb..4cf6e08 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
@@ -69,6 +69,7 @@
private Map<String, Ref> looseRefs;
private Map<String, Long> looseRefsMTime;
+ private Map<String, String> looseSymRefs;
private final File packedRefsFile;
@@ -96,6 +97,7 @@ void clearCache() {
looseRefs = new HashMap<String, Ref>();
looseRefsMTime = new HashMap<String, Long>();
packedRefs = new HashMap<String, Ref>();
+ looseSymRefs = new HashMap<String, String>();
packedRefsLastModified = 0;
packedRefsLength = 0;
}
@@ -348,15 +350,26 @@ private Ref readRefBasic(final String origName, final String name, final int dep
return ref;
}
- final String line;
+ String line = null;
try {
- line = readLine(loose);
+ Long cachedlastModified = looseRefsMTime.get(name);
+ if (cachedlastModified != null && cachedlastModified == mtime) {
+ line = looseSymRefs.get(name);
+ }
+ if (line == null) {
+ line = readLine(loose);
+ looseRefsMTime.put(name, mtime);
+ looseSymRefs.put(name, line);
+ }
} catch (FileNotFoundException notLoose) {
return packedRefs.get(name);
}
- if (line == null || line.length() == 0)
+ if (line == null || line.length() == 0) {
+ looseRefs.remove(origName);
+ looseRefsMTime.remove(origName);
return new Ref(Ref.Storage.LOOSE, origName, name, null);
+ }
if (line.startsWith("ref: ")) {
if (depth >= 5) {
--
1.6.0.3.640.g6331a
^ permalink raw reply related
* [EGIT PATCH] Use Constant.HEAD for "HEAD" references
From: Robin Rosenberg @ 2008-12-08 21:49 UTC (permalink / raw)
To: spearce; +Cc: git, Robin Rosenberg
Unit tests are excluded.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/core/internal/storage/GitFileHistory.java | 3 ++-
.../org/spearce/egit/core/op/BranchOperation.java | 7 ++++---
.../org/spearce/egit/core/op/ResetOperation.java | 4 ++--
.../egit/core/project/RepositoryMapping.java | 3 ++-
.../egit/ui/internal/actions/CommitAction.java | 13 +++++++------
.../actions/ResetQuickdiffBaselineAction.java | 3 ++-
.../egit/ui/internal/decorators/GitDocument.java | 3 ++-
.../internal/decorators/GitResourceDecorator.java | 3 ++-
.../egit/ui/internal/dialogs/CommitDialog.java | 3 ++-
.../egit/ui/internal/history/GitHistoryPage.java | 3 ++-
.../src/org/spearce/jgit/lib/IndexDiff.java | 2 +-
.../src/org/spearce/jgit/lib/Repository.java | 2 +-
.../spearce/jgit/transport/TransportAmazonS3.java | 3 ++-
.../org/spearce/jgit/transport/TransportSftp.java | 3 ++-
.../spearce/jgit/transport/WalkPushConnection.java | 2 +-
15 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
index c01c1c3..8b47c37 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java
@@ -20,6 +20,7 @@
import org.spearce.egit.core.Activator;
import org.spearce.egit.core.project.RepositoryMapping;
import org.spearce.jgit.lib.AnyObjectId;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.ObjectId;
import org.spearce.jgit.lib.Repository;
import org.spearce.jgit.revwalk.RevCommit;
@@ -78,7 +79,7 @@ private KidWalk buildWalk(final int flags) {
final Repository db = walk.getRepository();
final RevCommit root;
try {
- final AnyObjectId headId = db.resolve("HEAD");
+ final AnyObjectId headId = db.resolve(Constants.HEAD);
if (headId == null) {
Activator.logError("No HEAD revision available from Git"
+ " for project " + resource.getProject().getName()
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/BranchOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/BranchOperation.java
index c50d743..f472f29 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/BranchOperation.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/BranchOperation.java
@@ -21,6 +21,7 @@
import org.eclipse.team.core.TeamException;
import org.spearce.jgit.errors.CheckoutConflictException;
import org.spearce.jgit.lib.Commit;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.GitIndex;
import org.spearce.jgit.lib.RefLogWriter;
import org.spearce.jgit.lib.Repository;
@@ -105,7 +106,7 @@ private void writeHeadReflog() throws TeamException {
try {
RefLogWriter.writeReflog(repository, oldCommit.getCommitId(),
newCommit.getCommitId(), "checkout: moving to " + refName,
- "HEAD");
+ Constants.HEAD);
} catch (IOException e) {
throw new TeamException("Writing HEAD's reflog", e);
}
@@ -113,7 +114,7 @@ private void writeHeadReflog() throws TeamException {
private void updateHeadRef() throws TeamException {
try {
- repository.writeSymref("HEAD", refName);
+ repository.writeSymref(Constants.HEAD, refName);
} catch (IOException e) {
throw new TeamException("Updating HEAD to ref: " + refName, e);
}
@@ -157,7 +158,7 @@ private void lookupRefs() throws TeamException {
}
try {
- oldCommit = repository.mapCommit("HEAD");
+ oldCommit = repository.mapCommit(Constants.HEAD);
} catch (IOException e) {
throw new TeamException("Mapping commit HEAD commit", e);
}
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/ResetOperation.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/ResetOperation.java
index f6b10d0..c28d618 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/ResetOperation.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/ResetOperation.java
@@ -161,7 +161,7 @@ private void mapObjects() throws TeamException {
}
try {
- previousCommit = repository.mapCommit(repository.resolve("HEAD"));
+ previousCommit = repository.mapCommit(repository.resolve(Constants.HEAD));
} catch (IOException e) {
throw new TeamException("looking up HEAD commit", e);
}
@@ -233,7 +233,7 @@ private void writeReflog(String reflogRelPath) throws IOException {
private void writeReflogs() throws TeamException {
try {
- writeReflog("HEAD");
+ writeReflog(Constants.HEAD);
writeReflog(repository.getFullBranch());
} catch (IOException e) {
throw new TeamException("Writing reflogs", e);
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
index 8eb6072..e9df630 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
@@ -24,6 +24,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.team.core.RepositoryProvider;
import org.spearce.egit.core.GitProvider;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.GitIndex;
import org.spearce.jgit.lib.Repository;
import org.spearce.jgit.lib.Tree;
@@ -182,7 +183,7 @@ public boolean isResourceChanged(IResource rsrc) throws IOException, Unsupported
Repository repository = getRepository();
GitIndex index = repository.getIndex();
String repoRelativePath = getRepoRelativePath(rsrc);
- Tree headTree = repository.mapTree("HEAD");
+ Tree headTree = repository.mapTree(Constants.HEAD);
TreeEntry blob = headTree!=null ? headTree.findBlobMember(repoRelativePath) : null;
Entry entry = index.getEntry(repoRelativePath);
if (rsrc instanceof IFile && entry == null && blob == null)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
index d703048..5617b5a 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
@@ -33,6 +33,7 @@
import org.spearce.egit.core.project.RepositoryMapping;
import org.spearce.egit.ui.internal.dialogs.CommitDialog;
import org.spearce.jgit.lib.Commit;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.GitIndex;
import org.spearce.jgit.lib.IndexDiff;
import org.spearce.jgit.lib.ObjectId;
@@ -128,7 +129,7 @@ private void loadPreviousCommit() {
Repository repo = RepositoryMapping.getMapping(project).getRepository();
try {
- ObjectId parentId = repo.resolve("HEAD");
+ ObjectId parentId = repo.resolve(Constants.HEAD);
if (parentId != null)
previousCommit = repo.mapCommit(parentId);
} catch (IOException e) {
@@ -165,7 +166,7 @@ private String doCommits(CommitDialog commitDialog, String commitMessage,
Repository repo = tree.getRepository();
writeTreeWithSubTrees(tree);
- ObjectId currentHeadId = repo.resolve("HEAD");
+ ObjectId currentHeadId = repo.resolve(Constants.HEAD);
ObjectId[] parentIds;
if (amending) {
parentIds = previousCommit.getParentIds();
@@ -202,7 +203,7 @@ private String doCommits(CommitDialog commitDialog, String commitMessage,
ObjectWriter writer = new ObjectWriter(repo);
commit.setCommitId(writer.writeCommit(commit));
- final RefUpdate ru = repo.updateRef("HEAD");
+ final RefUpdate ru = repo.updateRef(Constants.HEAD);
ru.setNewObjectId(commit.getCommitId());
ru.setRefLogMessage(buildReflogMessage(commitMessage), false);
if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE) {
@@ -221,7 +222,7 @@ private void prepareTrees(IFile[] selectedItems,
for (IProject proj : getSelectedProjects()) {
Repository repo = RepositoryMapping.getMapping(proj).getRepository();
if (!treeMap.containsKey(repo))
- treeMap.put(repo, repo.mapTree("HEAD"));
+ treeMap.put(repo, repo.mapTree(Constants.HEAD));
}
}
@@ -233,7 +234,7 @@ private void prepareTrees(IFile[] selectedItems,
Repository repository = repositoryMapping.getRepository();
Tree projTree = treeMap.get(repository);
if (projTree == null) {
- projTree = repository.mapTree("HEAD");
+ projTree = repository.mapTree(Constants.HEAD);
if (projTree == null)
projTree = new Tree(repository);
treeMap.put(repository, projTree);
@@ -317,7 +318,7 @@ private void buildIndexHeadDiffList() throws IOException {
RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(project);
assert repositoryMapping != null;
Repository repository = repositoryMapping.getRepository();
- Tree head = repository.mapTree("HEAD");
+ Tree head = repository.mapTree(Constants.HEAD);
GitIndex index = repository.getIndex();
IndexDiff indexDiff = new IndexDiff(head, index);
indexDiff.diff();
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ResetQuickdiffBaselineAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ResetQuickdiffBaselineAction.java
index 597ee10..d7097ba 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ResetQuickdiffBaselineAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ResetQuickdiffBaselineAction.java
@@ -11,6 +11,7 @@
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.jface.action.IAction;
+import org.spearce.jgit.lib.Constants;
/**
* Changes the reference for the quickdiff to HEAD
@@ -19,6 +20,6 @@
@Override
protected IWorkspaceRunnable createOperation(IAction act, List selection) {
- return new QuickdiffBaselineOperation(getActiveRepository(), "HEAD");
+ return new QuickdiffBaselineOperation(getActiveRepository(), Constants.HEAD);
}
}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java
index 6e10144..a985a68 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java
@@ -16,6 +16,7 @@
import org.spearce.egit.core.GitProvider;
import org.spearce.egit.core.project.RepositoryMapping;
import org.spearce.egit.ui.Activator;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.IndexChangedEvent;
import org.spearce.jgit.lib.ObjectLoader;
import org.spearce.jgit.lib.RefsChangedEvent;
@@ -52,7 +53,7 @@ void populate() throws IOException {
repository.addRepositoryChangedListener(this);
String baseline = GitQuickDiffProvider.baseline.get(repository);
if (baseline == null)
- baseline = "HEAD";
+ baseline = Constants.HEAD;
Tree baselineTree = repository.mapTree(baseline);
if (baselineTree == null) {
Activator.logError("Could not resolve quickdiff baseline "
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java
index 97a0311..c3ae52d 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java
@@ -47,6 +47,7 @@
import org.spearce.egit.ui.Activator;
import org.spearce.egit.ui.UIIcons;
import org.spearce.egit.ui.UIText;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.GitIndex;
import org.spearce.jgit.lib.IndexChangedEvent;
import org.spearce.jgit.lib.RefsChangedEvent;
@@ -295,7 +296,7 @@ public void decorate(final Object element, final IDecoration decoration) {
Repository repository = mapped.getRepository();
GitIndex index = repository.getIndex();
String repoRelativePath = mapped.getRepoRelativePath(rsrc);
- Tree headTree = repository.mapTree("HEAD");
+ Tree headTree = repository.mapTree(Constants.HEAD);
TreeEntry blob = headTree!=null ? headTree.findBlobMember(repoRelativePath) : null;
Entry entry = index.getEntry(repoRelativePath);
if (entry == null) {
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
index 4f932f2..a16d441 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
@@ -49,6 +49,7 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.spearce.egit.core.project.RepositoryMapping;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.GitIndex;
import org.spearce.jgit.lib.PersonIdent;
import org.spearce.jgit.lib.Repository;
@@ -78,7 +79,7 @@ else if (columnIndex == 0) {
Repository repo = repositoryMapping.getRepository();
GitIndex index = repo.getIndex();
- Tree headTree = repo.mapTree("HEAD");
+ Tree headTree = repo.mapTree(Constants.HEAD);
String repoPath = repositoryMapping
.getRepoRelativePath(file);
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
index e3ff8d4..d718cd7 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
@@ -61,6 +61,7 @@
import org.spearce.egit.ui.UIPreferences;
import org.spearce.egit.ui.UIText;
import org.spearce.jgit.lib.AnyObjectId;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.IndexChangedEvent;
import org.spearce.jgit.lib.RefsChangedEvent;
import org.spearce.jgit.lib.Repository;
@@ -575,7 +576,7 @@ else if (db != map.getRepository())
final AnyObjectId headId;
try {
- headId = db.resolve("HEAD");
+ headId = db.resolve(Constants.HEAD);
} catch (IOException e) {
Activator.logError("Cannot parse HEAD in: "
+ db.getDirectory().getAbsolutePath(), e);
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/IndexDiff.java b/org.spearce.jgit/src/org/spearce/jgit/lib/IndexDiff.java
index 86f83b9..db395f3 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/IndexDiff.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/IndexDiff.java
@@ -59,7 +59,7 @@
* @throws IOException
*/
public IndexDiff(Repository repository) throws IOException {
- this.tree = repository.mapTree("HEAD");
+ this.tree = repository.mapTree(Constants.HEAD);
this.index = repository.getIndex();
}
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 b63ef18..a319c00 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -883,7 +883,7 @@ public String getPatch() throws IOException {
* @throws IOException
*/
public String getFullBranch() throws IOException {
- final File ptr = new File(getDirectory(),"HEAD");
+ final File ptr = new File(getDirectory(),Constants.HEAD);
final BufferedReader br = new BufferedReader(new FileReader(ptr));
String ref;
try {
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportAmazonS3.java b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportAmazonS3.java
index 9f1b516..a9fcdb9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportAmazonS3.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportAmazonS3.java
@@ -53,6 +53,7 @@
import org.spearce.jgit.errors.NotSupportedException;
import org.spearce.jgit.errors.TransportException;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.ObjectId;
import org.spearce.jgit.lib.ProgressMonitor;
import org.spearce.jgit.lib.Ref;
@@ -257,7 +258,7 @@ void writeFile(final String path, final byte[] data) throws IOException {
final TreeMap<String, Ref> avail = new TreeMap<String, Ref>();
readPackedRefs(avail);
readLooseRefs(avail);
- readRef(avail, "HEAD");
+ readRef(avail, Constants.HEAD);
return avail;
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportSftp.java b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportSftp.java
index 544e77c..d8b4ff7 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportSftp.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportSftp.java
@@ -53,6 +53,7 @@
import java.util.TreeMap;
import org.spearce.jgit.errors.TransportException;
+import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.ObjectId;
import org.spearce.jgit.lib.ProgressMonitor;
import org.spearce.jgit.lib.Ref;
@@ -372,7 +373,7 @@ private void mkdir_p(String path) throws IOException {
Map<String, Ref> readAdvertisedRefs() throws TransportException {
final TreeMap<String, Ref> avail = new TreeMap<String, Ref>();
readPackedRefs(avail);
- readRef(avail, ROOT_DIR + "HEAD", "HEAD");
+ readRef(avail, ROOT_DIR + Constants.HEAD, Constants.HEAD);
readLooseRefs(avail, ROOT_DIR + "refs", "refs/");
return avail;
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/WalkPushConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/WalkPushConnection.java
index 601ae66..3246ee6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/WalkPushConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/WalkPushConnection.java
@@ -336,7 +336,7 @@ private void createNewRepository(final List<RemoteRefUpdate> updates)
try {
final String ref = "ref: " + pickHEAD(updates) + "\n";
final byte[] bytes = Constants.encode(ref);
- dest.writeFile(ROOT_DIR + "HEAD", bytes);
+ dest.writeFile(ROOT_DIR + Constants.HEAD, bytes);
} catch (IOException e) {
throw new TransportException(uri, "cannot create HEAD", e);
}
--
1.6.0.3.640.g6331a
^ permalink raw reply related
* Re: git-svn not working when parent of cloned dir requires auth
From: D. Stuart Freeman @ 2008-12-08 22:07 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Eric Wong
In-Reply-To: <7v4p1e73tt.fsf@gitster.siamese.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]
In looking at the source of git-svn, I see:
' # there are currently some bugs that prevent multi-init/multi-fetch
# setups from working well without this.
$Git::SVN::_minimize_url = 1;'
I tried setting it to '0' and rerunning my clone. It no longer prompted
for a password, but it still failed to clone anything.
On Mon, Dec 08, 2008 at 01:30:06PM -0800, Junio C Hamano wrote:
> "D. Stuart Freeman" <stuart.freeman@et.gatech.edu> writes:
>
> > I'm trying to
> > 'git svn clone https://mware.ucdavis.edu/svn/ucd-sakai/gradebook-gwt -s'
> > that repo is setup to allow anonymous reading of that directory tree, but
> > git-svn prompts me for a password. I think git-svn is traversing up the
> > directory tree and encountering a directory that needs authn, can I prevent
> > it from doing that?
>
> That sounds suspiciously similar to what I observed long time ago:
>
> http://thread.gmane.org/gmane.comp.version-control.git/46361/focus=46558
>
> And $gmane/47151 in the thread, aka dc43166 (git-svn: don't minimize-url
> when doing an init that tracks multiple paths, 2007-05-19), supposed to
> have fixed it.
>
> Hmm... Eric?
--
D. Stuart Freeman
Georgia Institute of Technology
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: Can someone confirm what the contents of refs/heads/master means?
From: David Copeland @ 2008-12-08 22:21 UTC (permalink / raw)
To: Björn Steinbrink; +Cc: git
In-Reply-To: <20081208212636.GA6061@atjola.homenet>
Ah, that makes sense (I did another clone of another repo and did not
experience this behavior, so now that all makes sense).
Thanks!
Dave
On Mon, Dec 8, 2008 at 4:26 PM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
> On 2008.12.08 11:23:46 -0800, davetron5000 wrote:
>> I'm using git-svn to interact with an SVN repo that has branches.
>>
>> After my clone via:
>>
>> git svn clone $REPO/main -T trunk -b branches -t tags
>>
>> my 'master' branch pointed to one of the branches in svn and not to
>> the main trunk. (my .git/config looked correct for svn interaction,
>> i.e. trunk pointed to the right place).
>
> Just to clear up that bit as well. when the "fetch" finishes (which is
> part of the clone process), git-svn checks if there is a master branch,
> and if not, it creates one from the last commit it created. So if your
> last svn commit was to branch XYZ and not to trunk, master will
> reference that commit on branch XYZ.
>
> Björn
>
^ permalink raw reply
* Re: git-svn not working when parent of cloned dir requires auth
From: Eric Wong @ 2008-12-08 23:20 UTC (permalink / raw)
To: D. Stuart Freeman; +Cc: git, Junio C Hamano
In-Reply-To: <7v4p1e73tt.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
> "D. Stuart Freeman" <stuart.freeman@et.gatech.edu> writes:
>
> > I'm trying to
> > 'git svn clone https://mware.ucdavis.edu/svn/ucd-sakai/gradebook-gwt -s'
> > that repo is setup to allow anonymous reading of that directory tree, but
> > git-svn prompts me for a password. I think git-svn is traversing up the
> > directory tree and encountering a directory that needs authn, can I prevent
> > it from doing that?
>
> That sounds suspiciously similar to what I observed long time ago:
>
> http://thread.gmane.org/gmane.comp.version-control.git/46361/focus=46558
>
> And $gmane/47151 in the thread, aka dc43166 (git-svn: don't minimize-url
> when doing an init that tracks multiple paths, 2007-05-19), supposed to
> have fixed it.
There are some other auth issues that I'm not sure ever got resolved.
The SVN path->branch mapping code is a mess and has needed a rework for
a while... And I've gotten sick again this weekend. Tis the season...
Stuart:
For now, running the old style one-connection per-remote config
may be the easiest way to go:
------------ in your .git/config: ---------
[svn-remote "svn"]
url = https://mware.ucdavis.edu/svn/ucd-sakai/gradebook-gwt/trunk
fetch = :refs/remotes/trunk
[svn-remote "bloatedGxtAndVanilla"]
url = https://mware.ucdavis.edu/svn/ucd-sakai/gradebook-gwt/branches/bloatedGxtAndVanilla
fetch = :refs/remotes/bloatedGxtAndVanilla
[svn-remote "pre-GXT"]
url = https://mware.ucdavis.edu/svn/ucd-sakai/gradebook-gwt/branches/pre-GXT
fetch = :refs/remotes/pre-GXT
-------------------------------------------
Then run "git-svn fetch -i $SVN_REMOTE" for each svn-remote
--
Eric Wong
^ permalink raw reply
* Re: [PATCH v3] git-svn: Make following parents atomic
From: Eric Wong @ 2008-12-08 23:35 UTC (permalink / raw)
To: Deskin Miller; +Cc: Junio C Hamano, git
In-Reply-To: <20081208133131.GA9190@euler>
Deskin Miller <deskinm@umich.edu> wrote:
> find_parent_branch generates branch@rev type branches when one has to
> look back through SVN history to properly get the history for a branch
> copied from somewhere not already being tracked by git-svn. If in the
> process of fetching this history, git-svn is interrupted, then when one
> fetches again, it will use whatever was last fetched as the parent
> commit and fail to fetch any more history which it didn't get to before
> being terminated. This is especially troubling in that different
> git-svn copies of the same SVN repository can end up with different
> commit sha1s, incorrectly showing the history as divergent and
> precluding easy collaboration using git push and fetch.
>
> To fix this, when we initialise the Git::SVN object $gs to search for
> and perhaps fetch history, we check if there are any commits in SVN in
> the range between the current revision $gs is at, and the top revision
> for which we were asked to fill history. If there are commits we're
> missing in that range, we continue the fetch from the current revision
> to the top, properly getting all history before using it as the parent
> for the branch we're trying to create.
>
> Signed-off-by: Deskin Miller <deskinm@umich.edu>
Looks good Deskin, thanks
Acked-by: Eric Wong <normalperson@yhbt.net>
^ permalink raw reply
* [PATCH] submodule: Allow tracking of the newest revision of a branch in a submodule
From: Fabian Franz @ 2008-12-09 0:57 UTC (permalink / raw)
To: git; +Cc: hjemli, Fabian Franz
Submodules currently only allow tracking a specific revision
and each update in a submodule leads to a new commit in the
master repository. However some users may want to always track
the newest revision of a specific (named) tag or branch or HEAD.
For example the user might want to track a staging branch in all
submodules.
To allow this the "--track|-t <branch>" parameter was added to
git-submodule.sh, which is added to .gitmodules config file as
well as "track" parameter. This creates a new local branch on
checkout, which is tracking the remote branch in case the local
branch does not yet exist.
Technically the gitlink code was changed to read .git/HEAD.gitlink
if it exists instead of the normal HEAD. If you add 0000* as sha1
sum to .git/HEAD.gitlink the submodule code will always fetch HEAD.
The submodule code is creating this HEAD.gitlink file with 0000* on
"init" and "add".
Signed-off-by: Fabian Franz <git@fabian-franz.de>
---
Documentation/git-submodule.txt | 10 +++++++++-
git-submodule.sh | 31 ++++++++++++++++++++++++++++++-
refs.c | 6 ++++++
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index babaa9b..9c29678 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -9,7 +9,7 @@ git-submodule - Initialize, update or inspect submodules
SYNOPSIS
--------
[verse]
-'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
+'git submodule' [--quiet] add [-b branch] [-t|--track <branch>] [--] <repository> <path>
'git submodule' [--quiet] status [--cached] [--] [<path>...]
'git submodule' [--quiet] init [--] [<path>...]
'git submodule' [--quiet] update [--init] [--] [<path>...]
@@ -118,6 +118,10 @@ update::
If the submodule is not yet initialized, and you just want to use the
setting as stored in .gitmodules, you can automatically initialize the
submodule with the --init option.
++
+If you used --track or set the "track" option in .gitmodules this will
+automatically pull the newest updates from remote instead of tracking a
+specific revision.
summary::
Show commit summary between the given commit (defaults to HEAD) and
@@ -159,6 +163,10 @@ OPTIONS
--branch::
Branch of repository to add as submodule.
+-t::
+--track::
+ Branch/Tag/HEAD of repository to track in a submodule.
+
--cached::
This option is only valid for status and summary commands. These
commands typically use the commit found in the submodule HEAD, but
diff --git a/git-submodule.sh b/git-submodule.sh
index 2f47e06..9468d81 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -5,7 +5,7 @@
# Copyright (c) 2007 Lars Hjemli
USAGE="[--quiet] [--cached] \
-[add <repo> [-b branch] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \
+[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \
[--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
OPTIONS_SPEC=
. git-sh-setup
@@ -16,6 +16,7 @@ command=
branch=
quiet=
cached=
+track=
#
# print stuff on stdout unless -q was specified
@@ -130,6 +131,11 @@ cmd_add()
-q|--quiet)
quiet=1
;;
+ -t|--track)
+ case "$2" in '') usage ;; esac
+ track=$2
+ shift
+ ;;
--)
shift
break
@@ -197,12 +203,14 @@ cmd_add()
(unset GIT_DIR; cd "$path" && git checkout -f -q ${branch:+-b "$branch" "origin/$branch"}) ||
die "Unable to checkout submodule '$path'"
fi
+ [ -n "$track" ] && echo "0000000000000000000000000000000000000000" > $path/.git/HEAD.gitlink
git add "$path" ||
die "Failed to add submodule '$path'"
git config -f .gitmodules submodule."$path".path "$path" &&
git config -f .gitmodules submodule."$path".url "$repo" &&
+ git config -f .gitmodules submodule."$path".track "$track" &&
git add .gitmodules ||
die "Failed to register submodule '$path'"
}
@@ -327,10 +335,14 @@ cmd_update()
say "Maybe you want to use 'update --init'?"
continue
fi
+ track=$(git config -f .gitmodules submodule."$name".track)
if ! test -d "$path"/.git -o -f "$path"/.git
then
module_clone "$path" "$url" || exit
+
+ [ -n "$track" ] && echo "0000000000000000000000000000000000000000" > $path/.git/HEAD.gitlink
+
subsha1=
else
subsha1=$(unset GIT_DIR; cd "$path" &&
@@ -345,11 +357,28 @@ cmd_update()
then
force="-f"
fi
+ pull=
+ if [ "$sha1" = "0000000000000000000000000000000000000000" ]
+ then
+ [ -z "$track" ] && track="HEAD"
+ # if the local branch does not yet exist, create it
+ ( unset GIT_DIR; cd "$path"; git-show-ref --heads --tags -q "$track" || git branch --track "$track" "origin/$track" )
+ sha1="$track"
+ pull=1
+ fi
+
(unset GIT_DIR; cd "$path" && git-fetch &&
git-checkout $force -q "$sha1") ||
die "Unable to checkout '$sha1' in submodule path '$path'"
say "Submodule path '$path': checked out '$sha1'"
+
+ if [ "$pull" = "1" ]
+ then
+ # Now pull new updates from origin
+ ( unset GIT_DIR; cd "$path"; git-pull )
+ fi
+
fi
done
}
diff --git a/refs.c b/refs.c
index 33ced65..8246023 100644
--- a/refs.c
+++ b/refs.c
@@ -385,6 +385,12 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re
}
gitdir[len] = '/';
gitdir[++len] = '\0';
+
+ // Do not update submodule if HEAD.gitlink exists
+ retval = resolve_gitlink_ref_recursive(gitdir, len, "HEAD.gitlink", result, 0);
+ if (retval == 0)
+ return retval;
+
retval = resolve_gitlink_ref_recursive(gitdir, len, refname, result, 0);
free(gitdir);
return retval;
--
1.6.1.rc2.1.g363fe
^ permalink raw reply related
* Re: [PATCH] Define linkgit macro in [macros] section
From: Junio C Hamano @ 2008-12-09 1:26 UTC (permalink / raw)
To: Alexey Borzenkov; +Cc: git
In-Reply-To: <loom.20081208T201048-954@post.gmane.org>
Thanks, and it does not change the output with older version (at least
7.1.2, I'll try with the one they have at k.org later tonight) in any
negative way.
Will apply.
^ permalink raw reply
* Howto remove accidentally fetched remote tags?
From: roylee17 @ 2008-12-09 3:34 UTC (permalink / raw)
To: git
Hi,
Is there a convenient way to remove tags which accidentally( forgot adding
--no-tag ) fetched from a remote repo?
Will git add tag namespace( like branch namespace) in the future?
In this case, we can manage tags as convenient as branches.
Thanks.
Roy
--
View this message in context: http://n2.nabble.com/Howto-remove-accidentally-fetched-remote-tags--tp1632369p1632369.html
Sent from the git mailing list archive at Nabble.com.
^ permalink raw reply
* [PATCH] git-gui: Update Japanese translation for 0.12
From: Nanako Shiraishi @ 2008-12-09 3:42 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <20081208163628.GG31551@spearce.org>
Adds translation for one new message string.
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
---
po/ja.po | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/po/ja.po b/po/ja.po
index 8ba6417..09d60be 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: git-gui\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-11-16 13:56-0800\n"
-"PO-Revision-Date: 2008-11-26 19:17+0900\n"
+"POT-Creation-Date: 2008-12-08 08:31-0800\n"
+"PO-Revision-Date: 2008-12-09 06:27+0900\n"
"Last-Translator: しらいし ななこ <nanako3@lavabit.com>\n"
"Language-Team: Japanese\n"
"MIME-Version: 1.0\n"
@@ -2501,7 +2501,12 @@
msgid "Pushing changes to %s"
msgstr "%s へ変更をプッシュしています"
-#: lib/transport.tcl:72
+#: lib/transport.tcl:64
+#, tcl-format
+msgid "Mirroring to %s"
+msgstr "%s へミラーしています"
+
+#: lib/transport.tcl:82
#, tcl-format
msgid "Pushing %s %s to %s"
msgstr "%3$s へ %1$s %2$s をプッシュしています"
--
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
^ permalink raw reply related
* get upstream branch
From: Jeff Whiteside @ 2008-12-09 4:52 UTC (permalink / raw)
To: Git Mailing List
Hi,
Does anyone know how to programmatically get the upstream/parent
branch of a branch? I'm trying to write a gui, but looking at gitk's
tcl code isn't helping me much.
Thanks,
Whiteside
^ permalink raw reply
* Re: get upstream branch
From: Junio C Hamano @ 2008-12-09 5:35 UTC (permalink / raw)
To: Jeff Whiteside; +Cc: Git Mailing List
In-Reply-To: <3ab397d0812082052j6a45d05dr1c863aa260826f4@mail.gmail.com>
"Jeff Whiteside" <jeff.m.whiteside@gmail.com> writes:
> Does anyone know how to programmatically get the upstream/parent
> branch of a branch?
I do not think there is any plumbing facility to get that information, as
such "upstream/parent" concept did not exist back then when building the
whole Porcelain by scripting was the norm.
This should give "git branch -v -v it" to show the remote tracking
branch that is merged when "git pull" without any other parameters is
issued while on branch "it".
Obviously untested.
builtin-branch.c | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff --git c/builtin-branch.c w/builtin-branch.c
index 494cbac..565d99c 100644
--- c/builtin-branch.c
+++ w/builtin-branch.c
@@ -279,11 +279,15 @@ static int ref_cmp(const void *r1, const void *r2)
return strcmp(c1->name, c2->name);
}
-static void fill_tracking_info(struct strbuf *stat, const char *branch_name)
+static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
+ int verbosity)
{
int ours, theirs;
struct branch *branch = branch_get(branch_name);
+ if (verbosity > 1 && branch->merge[0]->dst)
+ strbuf_addf(stat, "(follows %s) ", branch->merge[0]->dst);
+
if (!stat_tracking_info(branch, &ours, &theirs) || (!ours && !theirs))
return;
if (!ours)
@@ -305,7 +309,7 @@ static int matches_merge_filter(struct commit *commit)
return (is_merged == (merge_filter == SHOW_MERGED));
}
-static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
+static void print_ref_item(struct ref_item *item, int maxwidth, int verbosity,
int abbrev, int current)
{
char c;
@@ -333,7 +337,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
color = COLOR_BRANCH_CURRENT;
}
- if (verbose) {
+ if (verbosity > 0) {
struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT;
const char *sub = " **** invalid ref ****";
@@ -345,7 +349,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
}
if (item->kind == REF_LOCAL_BRANCH)
- fill_tracking_info(&stat, item->name);
+ fill_tracking_info(&stat, item->name, verbosity);
printf("%c %s%-*s%s %s %s%s\n", c, branch_get_color(color),
maxwidth, item->name,
@@ -373,7 +377,7 @@ static int calc_maxwidth(struct ref_list *refs)
return w;
}
-static void print_ref_list(int kinds, int detached, int verbose, int abbrev, struct commit_list *with_commit)
+static void print_ref_list(int kinds, int detached, int verbosity, int abbrev, struct commit_list *with_commit)
{
int i;
struct ref_list ref_list;
@@ -393,7 +397,7 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str
(struct object *) filter, "");
ref_list.revs.limited = 1;
prepare_revision_walk(&ref_list.revs);
- if (verbose)
+ if (verbosity > 0)
ref_list.maxwidth = calc_maxwidth(&ref_list);
}
@@ -407,7 +411,7 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str
item.commit = head_commit;
if (strlen(item.name) > ref_list.maxwidth)
ref_list.maxwidth = strlen(item.name);
- print_ref_item(&item, ref_list.maxwidth, verbose, abbrev, 1);
+ print_ref_item(&item, ref_list.maxwidth, verbosity, abbrev, 1);
free(item.name);
}
@@ -415,7 +419,7 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str
int current = !detached &&
(ref_list.list[i].kind == REF_LOCAL_BRANCH) &&
!strcmp(ref_list.list[i].name, head);
- print_ref_item(&ref_list.list[i], ref_list.maxwidth, verbose,
+ print_ref_item(&ref_list.list[i], ref_list.maxwidth, verbosity,
abbrev, current);
}
@@ -498,7 +502,7 @@ static int opt_parse_merge_filter(const struct option *opt, const char *arg, int
int cmd_branch(int argc, const char **argv, const char *prefix)
{
int delete = 0, rename = 0, force_create = 0;
- int verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;
+ int verbosity = 0, abbrev = DEFAULT_ABBREV, detached = 0;
int reflog = 0;
enum branch_track track;
int kinds = REF_LOCAL_BRANCH;
@@ -506,7 +510,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
struct option options[] = {
OPT_GROUP("Generic options"),
- OPT__VERBOSE(&verbose),
+ OPT__VERBOSITY(&verbosity),
OPT_SET_INT( 0 , "track", &track, "set up tracking mode (see git-pull(1))",
BRANCH_TRACK_EXPLICIT),
OPT_BOOLEAN( 0 , "color", &branch_use_color, "use colored output"),
@@ -577,7 +581,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
if (delete)
return delete_branches(argc, argv, delete > 1, kinds);
else if (argc == 0)
- print_ref_list(kinds, detached, verbose, abbrev, with_commit);
+ print_ref_list(kinds, detached, verbosity, abbrev, with_commit);
else if (rename && (argc == 1))
rename_branch(head, argv[0], rename > 1);
else if (rename && (argc == 2))
^ permalink raw reply related
* Re: [PATCH 2/3] diff: allow turning on textconv explicitly for plumbing
From: Jeff King @ 2008-12-09 5:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v63lv842a.fsf@gitster.siamese.dyndns.org>
On Mon, Dec 08, 2008 at 12:27:25AM -0800, Junio C Hamano wrote:
> I imagine that web developers may want to use a textconv filter that
> replaces ">" with "\n>" on the HTML files their designer-colleagues throw
> in the source tree to make "git log -p" of the whole project easier to
Hrm, didn't you argue against textconv'ing non-binary contents earlier
in the cycle? At any rate, I agree that is a reasonable use. Maybe a
better name would have been "normalize" or "canonicalize".
> follow. When the developers would want to suggest improvements to what
> their designer-colleagues did, however, by running "git diff --stat -p" in
> their dirty work tree to produce a patch (like I just did just now,
> visible from the mnemonic prefixes below), they would want to disable
> textconv temporarily to get an appliable patch with --no-textconv option.
Yep, exactly. I use "git diff >patch" all the time instead of
format-patch.
> You raised an intriguing possibility to use textconv in blame. It would
> also be useful if we allowed "git show --textconv $blob" to pass the blob
> via textconv filter and any other transformation controlled by the
> attributes mechanism.. When "git show" sees the above command line, it
> only knows the blob object name and not the path, so we may need to allow
> a new option to tell the command to pretend as if the content came from a
> path, perhaps with a syntax like:
>
> $ git show --attribute-path=a/b/c $blob
> $ git show --attribute-path=a/b/c --textconv $blob
I think that makes sense. If you are going to implement a "use this as
the attribute path" feature, though, you might also want just "use these
attributes" which I can imagine being simpler in some cases. Like:
$ git show --attribute diff=whatever $blob
But on the subject of "other places to see textconv", another one I
considered was git log -S. I haven't looked to see if it even checks
binary files at all, but certainly if I was searching for some text
content I would want to find it in the text version (and depending on
the file format, there may be other binary cruft preventing you from
finding it in the binary version at all).
The series I posted was to show the text in gitk diffs. However, it does
nothing for finding text in gitk's "find commits introducing this
string", which I assume just uses git's pickaxe.
Unfortunately, it would probably be painfully slow. But still better
than nothing. One enhancement for textconv that I am considering is to
name the tempfiles based on the blob sha1. Then a smart helper could
cache expensive conversions if it wanted (and dumb helpers would
obviously just ignore the filename).
Side note: For one use case, storing word processor documents, this
approach seems sensible. But for my jpg example, it almost seems that
I could use git more efficiently by having two files: one with the exif
text, and one with the image content. And then I could "build" the
resulting tagged jpgs by combining the two, but operations on the text
would be very efficient. The downside, of course, being that the "build"
step is annoying, and consumes a ton of disk space. But it just occurred
to me as an alternate way to think about the use case.
> @@ -133,7 +133,8 @@ on.
> contents can be munged into human readable form and the difference
> between the results of the conversion can be viewed (obviously this
> cannot produce a patch that can be applied, so this is disabled in
> - format-patch among other things).
> + format-patch and plumbing, but if you really wanted to, you can enable
> + it by giving them --textconv command line option explicitly).
I wonder if we want to word this even more strongly: --textconv is there
and you can play with it if you want, but we are not promising that it
is part of the stable API yet.
-Peff
^ permalink raw reply
* Re: get upstream branch
From: Jeff King @ 2008-12-09 5:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff Whiteside, Git Mailing List
In-Reply-To: <7vljup6hdf.fsf@gitster.siamese.dyndns.org>
On Mon, Dec 08, 2008 at 09:35:08PM -0800, Junio C Hamano wrote:
> I do not think there is any plumbing facility to get that information, as
> such "upstream/parent" concept did not exist back then when building the
> whole Porcelain by scripting was the norm.
In one of my scripts I do something like this (actually this is not
straight from my script, as the operation there is "find all pairs of
local/remote branches" and this is "find the current upstream"):
ref=`git symbolic-ref HEAD`
head=${ref#refs/heads/}
remote=`git config branch.$head.remote`
branch=`git config branch.$head.merge`
echo refs/remote/$remote/${branch#refs/heads/}
And obviously this is missing error checking for the detached HEAD
(symbolic-ref should fail) and no tracking branch ($remote and/or $branch
will be empty) cases.
-Peff
^ permalink raw reply
* Re: Howto remove accidentally fetched remote tags?
From: Jeff King @ 2008-12-09 6:03 UTC (permalink / raw)
To: roylee17; +Cc: git
In-Reply-To: <1228793683956-1632369.post@n2.nabble.com>
On Mon, Dec 08, 2008 at 07:34:43PM -0800, roylee17 wrote:
> Is there a convenient way to remove tags which accidentally( forgot adding
> --no-tag ) fetched from a remote repo?
How about
$ git tag -l >tags-to-delete
$ $EDITOR tags-to-delete
$ xargs git tag -d <tags-to-delete
?
> Will git add tag namespace( like branch namespace) in the future?
> In this case, we can manage tags as convenient as branches.
I don't think there any plans for it. You can get something close by
doing this:
$ git config --add remote.origin.fetch '+refs/tags/*:refs/tags/origin/*'
$ git config remote.origin.tagopt --no-tags
The big difference is that you are asking to fetch _all_ tags here,
whereas the usual tag operation is to grab tags that point to anything
you are already getting via branches. But in practice, that is usually
the same content anyway.
-Peff
^ permalink raw reply
* [PATCH] Improve language in git-merge.txt and related docs
From: Ralf Wildenhues @ 2008-12-09 6:23 UTC (permalink / raw)
To: git
Improve some minor language and format issues like hyphenation,
phrases, spacing, word order, comma, attributes.
---
Hello,
Upon rereading git-merge*.txt, I noticed some language warts
and started fixing some minor issues. Please note that the
diff contains conflict markers as part of the text explaining
those markers; they will cause the standard commit hook to
complain.
I've tried to be consistent in that I searched Documentation/
for other instances of errors that I found and fixed them, too.
Patch is against master; please ping me if you'd like it split
up in some way.
Thanks,
Ralf
Documentation/git-fast-export.txt | 2 +-
Documentation/git-merge-base.txt | 19 +++++++++----------
Documentation/git-merge-file.txt | 12 ++++++------
Documentation/git-merge-index.txt | 6 +++---
Documentation/git-merge-tree.txt | 6 +++---
Documentation/git-merge.txt | 34 +++++++++++++++++-----------------
Documentation/git-mergetool.txt | 4 ++--
Documentation/merge-config.txt | 12 ++++++------
Documentation/merge-options.txt | 2 +-
9 files changed, 48 insertions(+), 49 deletions(-)
diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt
index b974e21..99a1c31 100644
--- a/Documentation/git-fast-export.txt
+++ b/Documentation/git-fast-export.txt
@@ -15,7 +15,7 @@ DESCRIPTION
This program dumps the given revisions in a form suitable to be piped
into 'git-fast-import'.
-You can use it as a human readable bundle replacement (see
+You can use it as a human-readable bundle replacement (see
linkgit:git-bundle[1]), or as a kind of an interactive
'git-filter-branch'.
diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt
index 2f0c525..767486c 100644
--- a/Documentation/git-merge-base.txt
+++ b/Documentation/git-merge-base.txt
@@ -16,15 +16,15 @@ DESCRIPTION
'git-merge-base' finds best common ancestor(s) between two commits to use
in a three-way merge. One common ancestor is 'better' than another common
ancestor if the latter is an ancestor of the former. A common ancestor
-that does not have any better common ancestor than it is a 'best common
+that does not have any better common ancestor is a 'best common
ancestor', i.e. a 'merge base'. Note that there can be more than one
-merge bases between two commits.
+merge base for a pair of commits.
-Among the two commits to compute their merge bases, one is specified by
+Among the two commits to compute the merge base from, one is specified by
the first commit argument on the command line; the other commit is a
(possibly hypothetical) commit that is a merge across all the remaining
-commits on the command line. As the most common special case, giving only
-two commits from the command line means computing the merge base between
+commits on the command line. As the most common special case, specifying only
+two commits on the command line means computing the merge base between
the given two commits.
OPTIONS
@@ -47,7 +47,7 @@ For example, with this topology:
the merge base between 'A' and 'B' is '1'.
Given three commits 'A', 'B' and 'C', `git merge-base A B C` will compute the
-merge base between 'A' and an hypothetical commit 'M', which is a merge
+merge base between 'A' and a hypothetical commit 'M', which is a merge
between 'B' and 'C'. For example, with this topology:
o---o---o---o---C
@@ -71,8 +71,7 @@ common ancestor between 'A' and 'M', but '1' is a better common ancestor,
because '2' is an ancestor of '1'. Hence, '2' is not a merge base.
When the history involves criss-cross merges, there can be more than one
-'best' common ancestors between two commits. For example, with this
-topology:
+'best' common ancestor for two commits. For example, with this topology:
---1---o---A
\ /
@@ -80,8 +79,8 @@ topology:
/ \
---2---o---o---B
-both '1' and '2' are merge-base of A and B. Neither one is better than
-the other (both are 'best' merge base). When `--all` option is not given,
+both '1' and '2' are merge-bases of A and B. Neither one is better than
+the other (both are 'best' merge bases). When the `--all` option is not given,
it is unspecified which best one is output.
Author
diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt
index 024ec01..3035373 100644
--- a/Documentation/git-merge-file.txt
+++ b/Documentation/git-merge-file.txt
@@ -15,17 +15,17 @@ SYNOPSIS
DESCRIPTION
-----------
-'git-file-merge' incorporates all changes that lead from the `<base-file>`
+'git-merge-file' incorporates all changes that lead from the `<base-file>`
to `<other-file>` into `<current-file>`. The result ordinarily goes into
`<current-file>`. 'git-merge-file' is useful for combining separate changes
to an original. Suppose `<base-file>` is the original, and both
-`<current-file>` and `<other-file>` are modifications of `<base-file>`.
-Then 'git-merge-file' combines both changes.
+`<current-file>` and `<other-file>` are modifications of `<base-file>`,
+then 'git-merge-file' combines both changes.
A conflict occurs if both `<current-file>` and `<other-file>` have changes
in a common segment of lines. If a conflict is found, 'git-merge-file'
-normally outputs a warning and brackets the conflict with <<<<<<< and
->>>>>>> lines. A typical conflict will look like this:
+normally outputs a warning and brackets the conflict with lines containing
+<<<<<<< and >>>>>>> markers. A typical conflict will look like this:
<<<<<<< A
lines in file A
@@ -60,7 +60,7 @@ OPTIONS
`<current-file>`.
-q::
- Quiet; do not warn about conflicts.
+ Quiet; do not warn about conflicts.
EXAMPLES
diff --git a/Documentation/git-merge-index.txt b/Documentation/git-merge-index.txt
index ff088c5..123e6d0 100644
--- a/Documentation/git-merge-index.txt
+++ b/Documentation/git-merge-index.txt
@@ -29,11 +29,11 @@ OPTIONS
Instead of stopping at the first failed merge, do all of them
in one shot - continue with merging even when previous merges
returned errors, and only return the error code after all the
- merges are over.
+ merges.
-q::
- Do not complain about failed merge program (the merge program
- failure usually indicates conflicts during merge). This is for
+ Do not complain about a failed merge program (a merge program
+ failure usually indicates conflicts during the merge). This is for
porcelains which might want to emit custom messages.
If 'git-merge-index' is called with multiple <file>s (or -a) then it
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index dbb0c18..f869a7f 100644
--- a/Documentation/git-merge-tree.txt
+++ b/Documentation/git-merge-tree.txt
@@ -14,14 +14,14 @@ DESCRIPTION
-----------
Reads three treeish, and output trivial merge results and
conflicting stages to the standard output. This is similar to
-what three-way read-tree -m does, but instead of storing the
+what three-way 'git read-tree -m' does, but instead of storing the
results in the index, the command outputs the entries to the
standard output.
This is meant to be used by higher level scripts to compute
-merge results outside index, and stuff the results back into the
+merge results outside of the index, and stuff the results back into the
index. For this reason, the output from the command omits
-entries that match <branch1> tree.
+entries that match the <branch1> tree.
Author
------
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 1f30830..f7be584 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -69,20 +69,20 @@ Three kinds of merge can happen:
simplest case, called "Already up-to-date."
* `HEAD` is already contained in the merged commit. This is the
- most common case especially when involved through 'git pull':
- you are tracking an upstream repository, committed no local
+ most common case especially when invoked from 'git pull':
+ you are tracking an upstream repository, have committed no local
changes and now you want to update to a newer upstream revision.
- Your `HEAD` (and the index) is updated to at point the merged
+ Your `HEAD` (and the index) is updated to point at the merged
commit, without creating an extra merge commit. This is
called "Fast-forward".
* Both the merged commit and `HEAD` are independent and must be
- tied together by a merge commit that has them both as its parents.
+ tied together by a merge commit that has both of them as its parents.
The rest of this section describes this "True merge" case.
The chosen merge strategy merges the two commits into a single
new source tree.
-When things cleanly merge, these things happen:
+When things merge cleanly, this is what happens:
1. The results are updated both in the index file and in your
working tree;
@@ -91,16 +91,16 @@ When things cleanly merge, these things happen:
4. The `HEAD` pointer gets advanced.
Because of 2., we require that the original state of the index
-file to match exactly the current `HEAD` commit; otherwise we
+file matches exactly the current `HEAD` commit; otherwise we
will write out your local changes already registered in your
index file along with the merge result, which is not good.
-Because 1. involves only the paths different between your
+Because 1. involves only those paths differing between your
branch and the remote branch you are pulling from during the
merge (which is typically a fraction of the whole tree), you can
have local modifications in your working tree as long as they do
not overlap with what the merge updates.
-When there are conflicts, these things happen:
+When there are conflicts, the following happens:
1. `HEAD` stays the same.
@@ -111,8 +111,8 @@ When there are conflicts, these things happen:
versions; stage1 stores the version from the common ancestor,
stage2 from `HEAD`, and stage3 from the remote branch (you
can inspect the stages with `git ls-files -u`). The working
- tree files have the result of "merge" program; i.e. 3-way
- merge result with familiar conflict markers `<<< === >>>`.
+ tree files contain the result of the "merge" program; i.e. 3-way
+ merge results with familiar conflict markers `<<< === >>>`.
4. No other changes are done. In particular, the local
modifications you had before you started merge will stay the
@@ -145,13 +145,13 @@ Git makes conflict resolution easy.
And here is another line that is cleanly resolved or unmodified.
------------
-The area a pair of conflicting changes happened is marked with markers
+The area where a pair of conflicting changes happened is marked with markers
"`<<<<<<<`", "`=======`", and "`>>>>>>>`". The part before the "`=======`"
-is typically your side, and the part after it is typically their side.
+is typically your side, and the part afterwards is typically their side.
-The default format does not show what the original said in the conflicted
-area. You cannot tell how many lines are deleted and replaced with the
-Barbie's remark by your side. The only thing you can tell is that your
+The default format does not show what the original said in the conflicting
+area. You cannot tell how many lines are deleted and replaced with
+Barbie's remark on your side. The only thing you can tell is that your
side wants to say it is hard and you'd prefer to go shopping, while the
other side wants to claim it is easy.
@@ -186,14 +186,14 @@ HOW TO RESOLVE CONFLICTS
After seeing a conflict, you can do two things:
- * Decide not to merge. The only clean-up you need are to reset
+ * Decide not to merge. The only clean-ups you need are to reset
the index file to the `HEAD` commit to reverse 2. and to clean
up working tree changes made by 2. and 3.; 'git-reset --hard' can
be used for this.
* Resolve the conflicts. Git will mark the conflicts in
the working tree. Edit the files into shape and
- 'git-add' to the index. 'git-commit' to seal the deal.
+ 'git-add' them to the index. Use 'git-commit' to seal the deal.
You can work through the conflict with a number of tools:
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index e0b2703..602e7c6 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -38,7 +38,7 @@ can configure the absolute path to kdiff3 by setting
`mergetool.kdiff3.path`. Otherwise, 'git-mergetool' assumes the
tool is available in PATH.
+
-Instead of running one of the known merge tool programs
+Instead of running one of the known merge tool programs,
'git-mergetool' can be customized to run an alternative program
by specifying the command line to invoke in a configuration
variable `mergetool.<tool>.cmd`.
@@ -55,7 +55,7 @@ of the file to which the merge tool should write the result of the
merge resolution.
+
If the custom merge tool correctly indicates the success of a
-merge resolution with its exit code then the configuration
+merge resolution with its exit code, then the configuration
variable `mergetool.<tool>.trustExitCode` can be set to `true`.
Otherwise, 'git-mergetool' will prompt the user to indicate the
success of the resolution after the custom tool has exited.
diff --git a/Documentation/merge-config.txt b/Documentation/merge-config.txt
index 86d5b26..1ff08ff 100644
--- a/Documentation/merge-config.txt
+++ b/Documentation/merge-config.txt
@@ -1,10 +1,10 @@
merge.conflictstyle::
Specify the style in which conflicted hunks are written out to
working tree files upon merge. The default is "merge", which
- shows `<<<<<<<` conflict marker, change made by one side,
- `=======` marker, change made by the other side, and then
- `>>>>>>>` marker. An alternate style, "diff3", adds `|||||||`
- marker and the original text before `=======` marker.
+ shows a `<<<<<<<` conflict marker, changes made by one side,
+ a `=======` marker, changes made by the other side, and then
+ a `>>>>>>>` marker. An alternate style, "diff3", adds a `|||||||`
+ marker and the original text before the `=======` marker.
merge.log::
Whether to include summaries of merged commits in newly created
@@ -32,10 +32,10 @@ merge.verbosity::
message if conflicts were detected. Level 1 outputs only
conflicts, 2 outputs conflicts and file changes. Level 5 and
above outputs debugging information. The default is level 2.
- Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
+ Can be overridden by the 'GIT_MERGE_VERBOSITY' environment variable.
merge.<driver>.name::
- Defines a human readable name for a custom low-level
+ Defines a human-readable name for a custom low-level
merge driver. See linkgit:gitattributes[5] for details.
merge.<driver>.driver::
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 427cdef..637b53f 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -12,7 +12,7 @@
-n::
--no-stat::
- Do not show diffstat at the end of the merge.
+ Do not show a diffstat at the end of the merge.
--summary::
--no-summary::
--
1.6.1.rc1.25.g27a91
^ permalink raw reply related
* Re: get upstream branch
From: Junio C Hamano @ 2008-12-09 6:43 UTC (permalink / raw)
To: Jeff King; +Cc: Jeff Whiteside, Git Mailing List
In-Reply-To: <20081209055629.GB2972@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> In one of my scripts I do something like this (actually this is not
> straight from my script, as the operation there is "find all pairs of
> local/remote branches" and this is "find the current upstream"):
>
> ref=`git symbolic-ref HEAD`
> head=${ref#refs/heads/}
> remote=`git config branch.$head.remote`
> branch=`git config branch.$head.merge`
> echo refs/remote/$remote/${branch#refs/heads/}
>
> And obviously this is missing error checking for the detached HEAD
> (symbolic-ref should fail) and no tracking branch ($remote and/or $branch
> will be empty) cases.
Yeah, add any nonstandard layout to that set of things that are missing,
but in practice it should not matter.
^ permalink raw reply
* Re: get upstream branch
From: Sverre Rabbelier @ 2008-12-09 6:46 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff Whiteside, Git Mailing List
In-Reply-To: <7vljup6hdf.fsf@gitster.siamese.dyndns.org>
On Tue, Dec 9, 2008 at 06:35, Junio C Hamano <gitster@pobox.com> wrote:
> This should give "git branch -v -v it" to show the remote tracking
> branch that is merged when "git pull" without any other parameters is
> issued while on branch "it".
But won't that leave Jeff Whiteside in the same position he was
already? As he is writing a GUI having the functionality in 'git
branch' is not useful, what with it being porcelain and all.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Why doesn't "git log --cherry-pick" work with ranges?
From: Kristian Amlie @ 2008-12-09 7:52 UTC (permalink / raw)
To: Git Mailing List
Is it because A..B internally translates to B ^A?
Is this something that would be easy to add?
--
Kristian Amlie
^ permalink raw reply
* [PATCH 1/2] diff: fix handling of binary rewrite diffs
From: Jeff King @ 2008-12-09 8:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
The current emit_rewrite_diff code always writes a text
patch without checking whether the content is binary. This
means that if you end up with a rewrite diff for a binary
file, you get lots of raw binary goo in your patch.
Instead, if we have binary files, then let's just skip
emit_rewrite_diff altogether. We will already have shown the
"dissimilarity index" line, so it is really about the diff
contents. If binary diffs are turned off, the "Binary files
a/file and b/file differ" message should be the same in
either case. If we do have binary patches turned on, there
isn't much point in making a less-efficient binary patch
that does a total rewrite; no human is going to read it, and
since binary patches don't apply with any fuzz anyway, the
result of application should be the same.
Signed-off-by: Jeff King <peff@peff.net>
---
I couldn't think of a good reason to want a different format of binary
patch for a rewrite versus a regular diff, but others may be able to.
In that case, you have to mimic the binary codepath somewhat in
emit_rewrite_diff; I started on it, but realized I was just copying the
code.
However, we should at least do something before 1.6.1; as it is, it
spews binary garbage.
I discovered this because one of my textconv'd files had a rewrite
(which apparently happens by changing a few lines in a word document :))
and gave me a bogus diff. However, the problem is not unique to
textconv; patch 1/2 handles binary files and 2/2 handles the textconv
case.
I didn't put the tests into the existing t4022-diff-rewrite because I
wanted to keep the textconv tests together with these tests, and I think
it makes sense to test features in isolation before testing them
together. IOW:
t4022 - rewrite works
t4030 - textconv works
t4031 - rewrite AND textconv work together
diff.c | 4 ++-
t/t4031-diff-rewrite-binary.sh | 42 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 1 deletions(-)
create mode 100755 t/t4031-diff-rewrite-binary.sh
diff --git a/diff.c b/diff.c
index f644947..ea958a2 100644
--- a/diff.c
+++ b/diff.c
@@ -1376,7 +1376,9 @@ static void builtin_diff(const char *name_a,
*/
if ((one->mode ^ two->mode) & S_IFMT)
goto free_ab_and_return;
- if (complete_rewrite) {
+ if (complete_rewrite &&
+ !diff_filespec_is_binary(one) &&
+ !diff_filespec_is_binary(two)) {
emit_rewrite_diff(name_a, name_b, one, two, o);
o->found_changes = 1;
goto free_ab_and_return;
diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh
new file mode 100755
index 0000000..4b522f7
--- /dev/null
+++ b/t/t4031-diff-rewrite-binary.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+test_description='rewrite diff on binary file'
+
+. ./test-lib.sh
+
+# We must be large enough to meet the MINIMUM_BREAK_SIZE
+# requirement.
+make_file() {
+ for i in 1 2 3 4 5 6 7 8 9 10; do
+ for j in 1 2 3 4 5 6 7 9 10; do
+ for k in 1 2 3 4 5; do
+ printf "$1\n"
+ done
+ done
+ done >file
+}
+
+test_expect_success 'create binary file with changes' '
+ make_file "\\0" &&
+ git add file &&
+ make_file "\\01"
+'
+
+test_expect_success 'vanilla diff is binary' '
+ git diff >diff &&
+ grep "Binary files a/file and b/file differ" diff
+'
+
+test_expect_success 'rewrite diff is binary' '
+ git diff -B >diff &&
+ grep "dissimilarity index" diff &&
+ grep "Binary files a/file and b/file differ" diff
+'
+
+test_expect_success 'rewrite diff can show binary patch' '
+ git diff -B --binary >diff &&
+ grep "dissimilarity index" diff &&
+ grep "GIT binary patch" diff
+'
+
+test_done
--
1.6.1.rc2.1.g8f945.dirty
^ permalink raw reply related
* [PATCH 2/2] diff: respect textconv in rewrite diffs
From: Jeff King @ 2008-12-09 8:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20081209081227.GA19626@coredump.intra.peff.net>
Currently we just skip rewrite diffs for binary files; this
patch makes an exception for files which will be textconv'd,
and actually performs the textconv before generating the
diff.
Conceptually, rewrite diffs should be in the exact same
format as the a non-rewrite diff, except that we refuse to
share any context. Thus it makes very little sense for "git
diff" to show a textconv'd diff, but for "git diff -B" to
show "Binary files differ".
Signed-off-by: Jeff King <peff@peff.net>
---
diff.c | 48 ++++++++++++++++++++++++++++++----------
t/t4031-diff-rewrite-binary.sh | 21 ++++++++++++++++-
2 files changed, 56 insertions(+), 13 deletions(-)
diff --git a/diff.c b/diff.c
index ea958a2..6dc19bc 100644
--- a/diff.c
+++ b/diff.c
@@ -229,6 +229,8 @@ static void emit_rewrite_diff(const char *name_a,
const char *name_b,
struct diff_filespec *one,
struct diff_filespec *two,
+ const char *textconv_one,
+ const char *textconv_two,
struct diff_options *o)
{
int lc_a, lc_b;
@@ -241,6 +243,8 @@ static void emit_rewrite_diff(const char *name_a,
const char *reset = diff_get_color(color_diff, DIFF_RESET);
static struct strbuf a_name = STRBUF_INIT, b_name = STRBUF_INIT;
const char *a_prefix, *b_prefix;
+ const char *data_one, *data_two;
+ size_t size_one, size_two;
if (diff_mnemonic_prefix && DIFF_OPT_TST(o, REVERSE_DIFF)) {
a_prefix = o->b_prefix;
@@ -262,8 +266,27 @@ static void emit_rewrite_diff(const char *name_a,
diff_populate_filespec(one, 0);
diff_populate_filespec(two, 0);
- lc_a = count_lines(one->data, one->size);
- lc_b = count_lines(two->data, two->size);
+ if (textconv_one) {
+ data_one = run_textconv(textconv_one, one, &size_one);
+ if (!data_one)
+ die("unable to read files to diff");
+ }
+ else {
+ data_one = one->data;
+ size_one = one->size;
+ }
+ if (textconv_two) {
+ data_two = run_textconv(textconv_two, two, &size_two);
+ if (!data_two)
+ die("unable to read files to diff");
+ }
+ else {
+ data_two = two->data;
+ size_two = two->size;
+ }
+
+ lc_a = count_lines(data_one, size_one);
+ lc_b = count_lines(data_two, size_two);
fprintf(o->file,
"%s--- %s%s%s\n%s+++ %s%s%s\n%s@@ -",
metainfo, a_name.buf, name_a_tab, reset,
@@ -273,9 +296,9 @@ static void emit_rewrite_diff(const char *name_a,
print_line_count(o->file, lc_b);
fprintf(o->file, " @@%s\n", reset);
if (lc_a)
- copy_file_with_prefix(o->file, '-', one->data, one->size, old, reset);
+ copy_file_with_prefix(o->file, '-', data_one, size_one, old, reset);
if (lc_b)
- copy_file_with_prefix(o->file, '+', two->data, two->size, new, reset);
+ copy_file_with_prefix(o->file, '+', data_two, size_two, new, reset);
}
static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)
@@ -1334,6 +1357,11 @@ static void builtin_diff(const char *name_a,
const char *a_prefix, *b_prefix;
const char *textconv_one = NULL, *textconv_two = NULL;
+ if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
+ textconv_one = get_textconv(one);
+ textconv_two = get_textconv(two);
+ }
+
diff_set_mnemonic_prefix(o, "a/", "b/");
if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
a_prefix = o->b_prefix;
@@ -1377,9 +1405,10 @@ static void builtin_diff(const char *name_a,
if ((one->mode ^ two->mode) & S_IFMT)
goto free_ab_and_return;
if (complete_rewrite &&
- !diff_filespec_is_binary(one) &&
- !diff_filespec_is_binary(two)) {
- emit_rewrite_diff(name_a, name_b, one, two, o);
+ (textconv_one || !diff_filespec_is_binary(one)) &&
+ (textconv_two || !diff_filespec_is_binary(two))) {
+ emit_rewrite_diff(name_a, name_b, one, two,
+ textconv_one, textconv_two, o);
o->found_changes = 1;
goto free_ab_and_return;
}
@@ -1388,11 +1417,6 @@ static void builtin_diff(const char *name_a,
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
die("unable to read files to diff");
- if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
- textconv_one = get_textconv(one);
- textconv_two = get_textconv(two);
- }
-
if (!DIFF_OPT_TST(o, TEXT) &&
( (diff_filespec_is_binary(one) && !textconv_one) ||
(diff_filespec_is_binary(two) && !textconv_two) )) {
diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh
index 4b522f7..72e5bfd 100755
--- a/t/t4031-diff-rewrite-binary.sh
+++ b/t/t4031-diff-rewrite-binary.sh
@@ -7,13 +7,15 @@ test_description='rewrite diff on binary file'
# We must be large enough to meet the MINIMUM_BREAK_SIZE
# requirement.
make_file() {
+ # common first line to help identify rewrite versus regular diff
+ printf "=\n" >file
for i in 1 2 3 4 5 6 7 8 9 10; do
for j in 1 2 3 4 5 6 7 9 10; do
for k in 1 2 3 4 5; do
printf "$1\n"
done
done
- done >file
+ done >>file
}
test_expect_success 'create binary file with changes' '
@@ -39,4 +41,21 @@ test_expect_success 'rewrite diff can show binary patch' '
grep "GIT binary patch" diff
'
+cat >dump <<'EOF'
+#!/bin/sh
+perl -e '$/ = undef; $_ = <>; s/./ord($&)/ge; print $_' < "$1"
+EOF
+chmod +x dump
+test_expect_success 'setup textconv' '
+ echo file diff=foo >.gitattributes &&
+ git config diff.foo.textconv "$PWD"/dump
+'
+
+test_expect_success 'rewrite diff respects textconv' '
+ git diff -B >diff &&
+ grep "dissimilarity index" diff &&
+ grep "^-61" diff &&
+ grep "^-0" diff
+'
+
test_done
--
1.6.1.rc2.1.g8f945.dirty
^ permalink raw reply related
* [PATCH/RFC] Allow writing loose objects that are corrupted in a pack file
From: Jan Krüger @ 2008-12-09 8:36 UTC (permalink / raw)
To: Git ML; +Cc: tyler
For fixing a corrupted repository by using backup copies of individual
files, allow write_sha1_file() to write loose files even if the object
already exists in a pack file, but only if the existing entry is marked
as corrupted.
Signed-off-by: Jan Krüger <jk@jk.gs>
---
On IRC I talked to rtyler who had a corrupted pack file and plenty of
object backups by way of cloned repositories. We decided to try
extracting the corrupted objects from the other object database and
injecting them into the broken repo as loose objects, but this failed
because sha1_write_file() refuses to write loose objects that are
already present in a pack file.
This patch expands the check to see if the pack entry has been marked
as corrupted and, if so, allows writing a loose object with the same
ID. Unfortunately, when Tyler tried a merge while using this patch,
something we didn't manage to track down happened and now git doesn't
consider the object corrupted anymore. I'm not sure enough that it
wasn't caused by the patch to submit this patch without hesitation.
Apart from that, I think the change is not all too great since it makes
write_sha1_file() walk the list of pack entries twice. That's a bit of
a waste.
So those are the reasons why I wanted a few opinions first. Another
reason is that there might be a way smarter method to fix this kind of
problem, in which case I'd love hearing about it for future reference.
sha1_file.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 6c0e251..17085cc 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2373,14 +2373,17 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
char hdr[32];
int hdrlen;
- /* Normally if we have it in the pack then we do not bother writing
- * it out into .git/objects/??/?{38} file.
- */
write_sha1_file_prepare(buf, len, type, sha1, hdr, &hdrlen);
if (returnsha1)
hashcpy(returnsha1, sha1);
- if (has_sha1_file(sha1))
- return 0;
+ /* Normally if we have it in the pack then we do not bother writing
+ * it out into .git/objects/??/?{38} file. We do, though, if there
+ * is no chance that we have an uncorrupted version of the object.
+ */
+ if (has_sha1_file(sha1)) {
+ if (has_loose_object(sha1) || !has_packed_and_bad(sha1))
+ return 0;
+ }
return write_loose_object(sha1, hdr, hdrlen, buf, len, 0);
}
--
1.6.0.4.766.g6fc4a
^ permalink raw reply related
* Re: How to clone git repository with git-svn meta-data included?
From: Michael J Gruber @ 2008-12-09 8:53 UTC (permalink / raw)
To: Grzegorz Kossakowski; +Cc: Michael J Gruber, git
In-Reply-To: <493D66BB.3060907@tuffmail.com>
Grzegorz Kossakowski venit, vidit, dixit 08.12.2008 19:26:
> Michael J Gruber pisze:
>> Could it be as simple as a missing "cd cocoon" between git clone and git
>> svn rebase? No, you probably did that.
>
> That would be too easy.
>
>> But note that you did not follow Peter's instructions. The point is that
>> your clone creates "remotes/origin/trunk" whereas Peter's instructions
>> mirror the source, creating "remotes/trunk", which is what git svn needs
>> (unless you say "git svn init -s --prefix=origin/" or "git config
>> svn-remote.svn.fetch trunk:refs/trunk" etc.). The prefix solution should
>> be the best.
>>
>> Michael
>>
>> P.S.: Peter starts off a different layout (standard svn remotes, which
>> need special instructions to be cloned). Ordinary clone + git svn init
>> --prefix=origin/ should work fine for the cocoon layout.
>
> This almost worked. Actually, Cocoon repository hosted on Jukka's server does not have local head
> named "trunk" so there is no remotes/origin/trunk created during cloning process.
>
> I had to run:
>
> git update-ref refs/remotes/origin/trunk refs/heads/master
Uhm, I misread gitweb output... So, cocoon really has remotes/trunk, so
that Peter's original suggestion would work. If the cocoon git-svn clone
isn't going to change then Peter's way of doing it might be the best: it
ensures that future pulls from origin (cocoon) will update the correct
refs so that you can pull/fetch from the git-svn clone (fast) and then
git-svn rebase rather than git-svn rebasing directly, which would fetch
new commits from the svn repo first (slow).
I think all in all it shows that git-svns default location for branches
is not the best choice: they're not local, but they're no "proper"
remotes either (unless you use --prefix).
Michael
^ permalink raw reply
* is gitosis secure?
From: Thomas Koch @ 2008-12-09 8:56 UTC (permalink / raw)
To: Git Mailing List, dabe
Sorry for the shameless subject, but I presented gitosis yesterday to
our sysadmin and he wasn't much delighted to learn, that write access to
repositories hosted with gitosis would need SSH access.
So could you help me out in this discussion, whether to use or not to
use gitosis?
Our admin would prefer to not open SSH at all outside our LAN, but
developers would need to have write access also outside the office.
Best regards,
--
Thomas Koch, Software Developer
http://www.koch.ro
Young Media Concepts GmbH
Sonnenstr. 4
CH-8280 Kreuzlingen
Switzerland
Tel +41 (0)71 / 508 24 86
Fax +41 (0)71 / 560 53 89
Mobile +49 (0)170 / 753 89 16
Web www.ymc.ch
^ 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