* Re: git-rev-parse --symbolic-abbrev-name
From: Miklos Vajna @ 2009-01-04 22:38 UTC (permalink / raw)
To: Arnaud Lacombe; +Cc: Junio C Hamano, Karl Chen, David Aguilar, Git mailing list
In-Reply-To: <1a69a9d80901041223r1f3d2956ne05996793bb23e97@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 325 bytes --]
On Sun, Jan 04, 2009 at 03:23:03PM -0500, Arnaud Lacombe <lacombar@gmail.com> wrote:
> ps: I choose --symbolic-short-name as the opposite of
> --symbolic-full-name for consistency.
> ps2: sorry for the bogus mime-type
That's not a problem, just don't attach your patch. Please read
Documentation/SubmittingPatches.
Thanks.
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* [EGIT PATCH] Sorting commit items by click on the table header in commit dialog.
From: Vasyl' Vavrychuk @ 2009-01-04 22:46 UTC (permalink / raw)
To: git
In order to implement new feature I have replaced class associated with every table row.
CommitItem class encapsulate data that commit dialog manipulates with.
Comparators are written using idiom from http://tobega.blogspot.com/2008/05/beautiful-enums.html.
Clicks on a certain column are handled in HeaderSelectionListener class.
Signed-off-by: Vasyl Vavrychuk <vvavrychuk@gmail.com>
---
.../egit/ui/internal/actions/CommitAction.java | 2 +-
.../egit/ui/internal/dialogs/CommitDialog.java | 248 ++++++++++++++------
2 files changed, 176 insertions(+), 74 deletions(-)
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..779596c 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
@@ -139,7 +139,7 @@ private void loadPreviousCommit() {
private void performCommit(CommitDialog commitDialog, String commitMessage)
throws TeamException {
// System.out.println("Commit Message: " + commitMessage);
- IFile[] selectedItems = commitDialog.getSelectedItems();
+ IFile[] selectedItems = commitDialog.getSelectedFiles();
HashMap<Repository, Tree> treeMap = new HashMap<Repository, Tree>();
try {
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..a0598ff 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
@@ -15,6 +15,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
@@ -28,9 +29,11 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
@@ -62,56 +65,38 @@
*/
public class CommitDialog extends Dialog {
+ class CommitContentProvider implements IStructuredContentProvider {
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // Empty
+ }
+
+ public void dispose() {
+ // Empty
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return items.toArray();
+ }
+
+ }
+
class CommitLabelProvider extends WorkbenchLabelProvider implements
ITableLabelProvider {
public String getColumnText(Object obj, int columnIndex) {
- IFile file = (IFile) obj;
- if (columnIndex == 1)
- return file.getProject().getName() + ": "
- + file.getProjectRelativePath();
+ CommitItem item = (CommitItem) obj;
- else if (columnIndex == 0) {
- String prefix = "Unknown";
+ switch (columnIndex) {
+ case 0:
+ return item.status;
- try {
- RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(file.getProject());
-
- Repository repo = repositoryMapping.getRepository();
- GitIndex index = repo.getIndex();
- Tree headTree = repo.mapTree("HEAD");
-
- String repoPath = repositoryMapping
- .getRepoRelativePath(file);
- TreeEntry headEntry = headTree.findBlobMember(repoPath);
- boolean headExists = headTree.existsBlob(repoPath);
-
- Entry indexEntry = index.getEntry(repoPath);
- if (headEntry == null) {
- prefix = "Added";
- if (indexEntry.isModified(repositoryMapping.getWorkDir()))
- prefix = "Added, index diff";
- } else if (indexEntry == null) {
- prefix = "Removed";
- } else if (headExists
- && !headEntry.getId().equals(
- indexEntry.getObjectId())) {
- prefix = "Modified";
-
-
- if (indexEntry.isModified(repositoryMapping.getWorkDir()))
- prefix = "Mod., index diff";
- } else if (!new File(repositoryMapping.getWorkDir(), indexEntry.getName()).isFile()) {
- prefix = "Rem., not staged";
- } else if (indexEntry.isModified(repositoryMapping.getWorkDir())) {
- prefix = "Mod., not staged";
- }
-
- } catch (Exception e) {
- }
+ case 1:
+ return item.file.getProject().getName() + ": "
+ + item.file.getProjectRelativePath();
- return prefix;
+ default:
+ return null;
}
- return null;
}
public Image getColumnImage(Object element, int columnIndex) {
@@ -121,7 +106,7 @@ public Image getColumnImage(Object element, int columnIndex) {
}
}
- ArrayList<IFile> files;
+ ArrayList<CommitItem> items = new ArrayList<CommitItem>();
/**
* @param parentShell
@@ -227,30 +212,17 @@ public void widgetDefaultSelected(SelectionEvent arg0) {
TableColumn statCol = new TableColumn(resourcesTable, SWT.LEFT);
statCol.setText("Status");
statCol.setWidth(150);
+ statCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByStatus));
TableColumn resourceCol = new TableColumn(resourcesTable, SWT.LEFT);
resourceCol.setText("File");
resourceCol.setWidth(415);
+ resourceCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByFile));
filesViewer = new CheckboxTableViewer(resourcesTable);
- filesViewer.setContentProvider(new IStructuredContentProvider() {
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- // Empty
- }
-
- public void dispose() {
- // Empty
- }
-
- public Object[] getElements(Object inputElement) {
- return files.toArray();
- }
-
- });
+ filesViewer.setContentProvider(new CommitContentProvider());
filesViewer.setLabelProvider(new CommitLabelProvider());
- filesViewer.setInput(files);
+ filesViewer.setInput(items);
filesViewer.setAllChecked(true);
filesViewer.getTable().setMenu(getContextMenu());
@@ -271,15 +243,15 @@ public void handleEvent(Event arg0) {
try {
ArrayList<GitIndex> changedIndexes = new ArrayList<GitIndex>();
for (Iterator<Object> it = sel.iterator(); it.hasNext();) {
- IFile file = (IFile) it.next();
+ CommitItem commitItem = (CommitItem) it.next();
- IProject project = file.getProject();
+ IProject project = commitItem.file.getProject();
RepositoryMapping map = RepositoryMapping.getMapping(project);
Repository repo = map.getRepository();
GitIndex index = null;
index = repo.getIndex();
- Entry entry = index.getEntry(map.getRepoRelativePath(file));
+ Entry entry = index.getEntry(map.getRepoRelativePath(commitItem.file));
if (entry != null && entry.isModified(map.getWorkDir())) {
entry.update(new File(map.getWorkDir(), entry.getName()));
if (!changedIndexes.contains(index))
@@ -302,6 +274,47 @@ public void handleEvent(Event arg0) {
return menu;
}
+ private static String getFileStatus(IFile file) {
+ String prefix = "Unknown";
+
+ try {
+ RepositoryMapping repositoryMapping = RepositoryMapping
+ .getMapping(file.getProject());
+
+ Repository repo = repositoryMapping.getRepository();
+ GitIndex index = repo.getIndex();
+ Tree headTree = repo.mapTree("HEAD");
+
+ String repoPath = repositoryMapping.getRepoRelativePath(file);
+ TreeEntry headEntry = headTree.findBlobMember(repoPath);
+ boolean headExists = headTree.existsBlob(repoPath);
+
+ Entry indexEntry = index.getEntry(repoPath);
+ if (headEntry == null) {
+ prefix = "Added";
+ if (indexEntry.isModified(repositoryMapping.getWorkDir()))
+ prefix = "Added, index diff";
+ } else if (indexEntry == null) {
+ prefix = "Removed";
+ } else if (headExists
+ && !headEntry.getId().equals(indexEntry.getObjectId())) {
+ prefix = "Modified";
+
+ if (indexEntry.isModified(repositoryMapping.getWorkDir()))
+ prefix = "Mod., index diff";
+ } else if (!new File(repositoryMapping.getWorkDir(), indexEntry
+ .getName()).isFile()) {
+ prefix = "Rem., not staged";
+ } else if (indexEntry.isModified(repositoryMapping.getWorkDir())) {
+ prefix = "Mod., not staged";
+ }
+
+ } catch (Exception e) {
+ }
+
+ return prefix;
+ }
+
/**
* @return The message the user entered
*/
@@ -323,7 +336,7 @@ public void setCommitMessage(String s) {
private boolean amending = false;
private boolean amendAllowed = true;
- private ArrayList<IFile> selectedItems = new ArrayList<IFile>();
+ private ArrayList<IFile> selectedFiles = new ArrayList<IFile>();
private String previousCommitMessage = "";
/**
@@ -331,15 +344,51 @@ public void setCommitMessage(String s) {
*
* @param items
*/
- public void setSelectedItems(IFile[] items) {
- Collections.addAll(selectedItems, items);
+ public void setSelectedFiles(IFile[] items) {
+ Collections.addAll(selectedFiles, items);
}
/**
* @return the resources selected by the user to commit.
*/
- public IFile[] getSelectedItems() {
- return selectedItems.toArray(new IFile[0]);
+ public IFile[] getSelectedFiles() {
+ return selectedFiles.toArray(new IFile[0]);
+ }
+
+ class HeaderSelectionListener extends SelectionAdapter {
+
+ private CommitItem.Order order;
+
+ private boolean reversed;
+
+ public HeaderSelectionListener(CommitItem.Order order) {
+ this.order = order;
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TableColumn column = (TableColumn)e.widget;
+ Table table = column.getParent();
+
+ if (column == table.getSortColumn()) {
+ reversed = !reversed;
+ } else {
+ reversed = false;
+ }
+ table.setSortColumn(column);
+
+ Comparator<CommitItem> comparator;
+ if (reversed) {
+ comparator = order.descending();
+ table.setSortDirection(SWT.DOWN);
+ } else {
+ comparator = order;
+ table.setSortDirection(SWT.UP);
+ }
+
+ filesViewer.setComparator(new CommitViewerComparator(comparator));
+ }
+
}
@Override
@@ -350,9 +399,9 @@ protected void okPressed() {
amending = amendingButton.getSelection();
Object[] checkedElements = filesViewer.getCheckedElements();
- selectedItems.clear();
+ selectedFiles.clear();
for (Object obj : checkedElements)
- selectedItems.add((IFile) obj);
+ selectedFiles.add(((CommitItem) obj).file);
if (commitMessage.trim().length() == 0) {
MessageDialog.openWarning(getShell(), "No message", "You must enter a commit message");
@@ -368,7 +417,7 @@ protected void okPressed() {
}
} else author = null;
- if (selectedItems.isEmpty() && !amending) {
+ if (selectedFiles.isEmpty() && !amending) {
MessageDialog.openWarning(getShell(), "No items selected", "No items are currently selected to be committed.");
return;
}
@@ -382,7 +431,13 @@ protected void okPressed() {
* @param files potentially affected by a new commit
*/
public void setFileList(ArrayList<IFile> files) {
- this.files = files;
+ items.clear();
+ for (IFile file : files) {
+ CommitItem item = new CommitItem();
+ item.status = getFileStatus(file);
+ item.file = file;
+ items.add(item);
+ }
}
@Override
@@ -468,3 +523,50 @@ protected int getShellStyle() {
return super.getShellStyle() | SWT.RESIZE;
}
}
+
+class CommitItem {
+ String status;
+
+ IFile file;
+
+ public static enum Order implements Comparator<CommitItem> {
+ ByStatus() {
+
+ public int compare(CommitItem o1, CommitItem o2) {
+ return o1.status.compareTo(o2.status);
+ }
+
+ },
+
+ ByFile() {
+
+ public int compare(CommitItem o1, CommitItem o2) {
+ return o1.file.getProjectRelativePath().toString().
+ compareTo(o2.file.getProjectRelativePath().toString());
+ }
+
+ };
+
+ public Comparator<CommitItem> ascending() {
+ return this;
+ }
+
+ public Comparator<CommitItem> descending() {
+ return Collections.reverseOrder(this);
+ }
+ }
+}
+
+class CommitViewerComparator extends ViewerComparator {
+
+ public CommitViewerComparator(Comparator comparator){
+ super(comparator);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ return getComparator().compare(e1, e2);
+ }
+
+}
--
1.5.6.1.1071.g76fb
^ permalink raw reply related
* Re: [PATCH next] git-cherry usage: correct nesting of commit-ish options
From: Miklos Vajna @ 2009-01-04 22:47 UTC (permalink / raw)
To: Markus Heidelberg; +Cc: gitster, git
In-Reply-To: <200901041901.18801.markus.heidelberg@web.de>
[-- Attachment #1: Type: text/plain, Size: 428 bytes --]
On Sun, Jan 04, 2009 at 07:01:18PM +0100, Markus Heidelberg <markus.heidelberg@web.de> wrote:
> > AFAIK sending patches against next is not preferred at all.
>
> From Documentation/SubmittingPatches:
>
> If you are preparing a work based on "next" branch,
> that is fine, but please mark it as such.
Ouch, then sorry for the misinformation. (Especially that it turns out
Junio added that line in 45d2b286.)
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.
From: Robin Rosenberg @ 2009-01-04 23:04 UTC (permalink / raw)
To: Vasyl' Vavrychuk, Shawn O. Pearce; +Cc: git
In-Reply-To: <gjrcni$9q$1@ger.gmane.org>
söndag 04 januari 2009 23:20:19 skrev Vasyl' Vavrychuk:
> Also fixed:
> 1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
> 2. Possible NullPointerException warning.
> 3. Unnecessery function parameter warning.
Thanks for your interest in the projects. Most changes from a 30 seconds review look reasonable.
However we don't apply changes this way. From your comments it seems we'd require about
five patches since the changes are of very different types.
-- robin
> diff --git a/org.spearce.egit.core.test/META-INF/MANIFEST.MF b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
> index ee5f277..e8bcc79 100644
> --- a/org.spearce.egit.core.test/META-INF/MANIFEST.MF
> +++ b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
> @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
> org.spearce.egit.ui,
> org.spearce.jgit,
> org.eclipse.core.filesystem
> -Eclipse-LazyStart: true
> +Bundle-ActivationPolicy: lazy
Any pointers on this? (so I can learn)
> 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..61c32ce 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
> @@ -50,11 +50,11 @@
> GitFileHistory(final IResource rsrc, final int flags,
> final IProgressMonitor monitor) {
> resource = rsrc;
> - walk = buildWalk(flags);
> + walk = buildWalk(/*flags*/);
> revisions = buildRevisions(monitor, flags);
> }
> - private KidWalk buildWalk(final int flags) {
> + private KidWalk buildWalk(/*final int flags*/) {
Can't we just drop the parameter completely and wipe every trace of it?
> final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
> if (rm == null) {
> Activator.logError("Git not attached to project "
> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
> index 04130db..db5f20b 100644
> --- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
> @@ -48,9 +48,9 @@
> * a Git repository.
> */
> public class GitProjectData {
> - private static final Map projectDataCache = new HashMap();
> + private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
>
> - private static final Map repositoryCache = new HashMap();
> + private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();
Been thinking about doing this myself but always found something more interesting to do. Good.
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
> index dcc53cd..4700510 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
> @@ -175,8 +175,9 @@ public void back(int delta) {
> // space so this prunes our search more quickly.
> //
> ptr -= Constants.OBJECT_ID_LENGTH;
> - while (raw[--ptr] != ' ')
> - /* nothing */;
> + while (raw[--ptr] != ' ') {
> + /* nothing */
> + }
Not sure if this buys us anything. I wouldn't react if original code was either way, but
changing it seems unnecessary.
-- robin
^ permalink raw reply
* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.
From: Vasyl' Vavrychuk @ 2009-01-04 23:26 UTC (permalink / raw)
To: git
In-Reply-To: <gjrcni$9q$1@ger.gmane.org>
Not sure what is right:
public abstract class AnyObjectId implements Comparable<ObjectId> {
or
public abstract class AnyObjectId implements Comparable<AnyObjectId> {
IMHO second, but class AnyObjectId contains some compareTo(ObjectId).
Also not sure if this bunch of changes is complete enough. Maybe it's better to make more fixes in this direction and then commit.
^ permalink raw reply
* Re: git-branch --print-current
From: Junio C Hamano @ 2009-01-05 0:41 UTC (permalink / raw)
To: demerphq
Cc: Shawn O. Pearce, Karl Chen, Miklos Vajna, David Aguilar,
Git mailing list
In-Reply-To: <9b18b3110901040535m1f67cb7er95823d31443ee971@mail.gmail.com>
demerphq <demerphq@gmail.com> writes:
> The version im using, from git version 1.6.0.4.724.ga0d3a produces the
> following error:
>
> cut: ./HEAD: No such file or directory
>
> when in the .git/refs directory.
Personally, I think you are nuts to be in .git/refs and want to use that
information for anything useful, but if it is an easy enough fix, a patch
would be useful.
Shawn?
^ permalink raw reply
* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.
From: Vasyl' Vavrychuk @ 2009-01-05 1:08 UTC (permalink / raw)
To: git; +Cc: Shawn O. Pearce, git
In-Reply-To: <200901050004.41531.robin.rosenberg.lists@dewire.com>
Robin Rosenberg wrote:
> söndag 04 januari 2009 23:20:19 skrev Vasyl' Vavrychuk:
>> Also fixed:
>> 1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
>> 2. Possible NullPointerException warning.
>> 3. Unnecessery function parameter warning.
>
> Thanks for your interest in the projects.
> Most changes from a 30 seconds review look reasonable.
> However we don't apply changes this way. From your comments it seems we'd require about
> five patches since the changes are of very different types.
I thought that commit is trivial. But maybe series of patches will be better because of an ability to revert what we want.
>
> -- robin
>
>> diff --git a/org.spearce.egit.core.test/META-INF/MANIFEST.MF b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> index ee5f277..e8bcc79 100644
>> --- a/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> +++ b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
>> org.spearce.egit.ui,
>> org.spearce.jgit,
>> org.eclipse.core.filesystem
>> -Eclipse-LazyStart: true
>> +Bundle-ActivationPolicy: lazy
>
> Any pointers on this? (so I can learn)
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/bundle_manifest.html
The Eclipse-AutoStart and Eclipse-LazyStart headers have been deprecated in Eclipse 3.4
>
>> 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..61c32ce 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
>> @@ -50,11 +50,11 @@
>> GitFileHistory(final IResource rsrc, final int flags,
>> final IProgressMonitor monitor) {
>> resource = rsrc;
>> - walk = buildWalk(flags);
>> + walk = buildWalk(/*flags*/);
>> revisions = buildRevisions(monitor, flags);
>> }
>> - private KidWalk buildWalk(final int flags) {
>> + private KidWalk buildWalk(/*final int flags*/) {
> Can't we just drop the parameter completely and wipe every trace of it?
OK
>> final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
>> if (rm == null) {
>> Activator.logError("Git not attached to project "
>> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> index 04130db..db5f20b 100644
>> --- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> @@ -48,9 +48,9 @@
>> * a Git repository.
>> */
>> public class GitProjectData {
>> - private static final Map projectDataCache = new HashMap();
>> + private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
>>
>> - private static final Map repositoryCache = new HashMap();
>> + private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();
> Been thinking about doing this myself but always found something more interesting to do. Good.
Hope that we will have a generic version of SWT/JFace sometime. Because now I do not know how to handle an inter operation between generic collections and SWT, use SuppressWarning there maybe?
>> diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> index dcc53cd..4700510 100644
>> --- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> +++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> @@ -175,8 +175,9 @@ public void back(int delta) {
>> // space so this prunes our search more quickly.
>> //
>> ptr -= Constants.OBJECT_ID_LENGTH;
>> - while (raw[--ptr] != ' ')
>> - /* nothing */;
>> + while (raw[--ptr] != ' ') {
>> + /* nothing */
>> + }
> Not sure if this buys us anything. I wouldn't react if original code was either way, but
> changing it seems unnecessary.
With an old version I get "Empty control-flow statement" warning, I've checked org.eclipse.jdt.core.prefs file, there is:
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
^ permalink raw reply
* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.
From: Vasyl' Vavrychuk @ 2009-01-05 1:13 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: Shawn O. Pearce, git
In-Reply-To: <200901050004.41531.robin.rosenberg.lists@dewire.com>
Robin Rosenberg wrote:
> söndag 04 januari 2009 23:20:19 skrev Vasyl' Vavrychuk:
>> Also fixed:
>> 1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
>> 2. Possible NullPointerException warning.
>> 3. Unnecessery function parameter warning.
>
> Thanks for your interest in the projects.
> Most changes from a 30 seconds review look reasonable.
> However we don't apply changes this way. From your comments it seems we'd require about
> five patches since the changes are of very different types.
I thought that commit is trivial. But maybe series of patches will be better because of an ability to revert what we want.
>
> -- robin
>
>> diff --git a/org.spearce.egit.core.test/META-INF/MANIFEST.MF b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> index ee5f277..e8bcc79 100644
>> --- a/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> +++ b/org.spearce.egit.core.test/META-INF/MANIFEST.MF
>> @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
>> org.spearce.egit.ui,
>> org.spearce.jgit,
>> org.eclipse.core.filesystem
>> -Eclipse-LazyStart: true
>> +Bundle-ActivationPolicy: lazy
>
> Any pointers on this? (so I can learn)
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/bundle_manifest.html
The Eclipse-AutoStart and Eclipse-LazyStart headers have been deprecated in Eclipse 3.4
>
>> 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..61c32ce 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
>> @@ -50,11 +50,11 @@
>> GitFileHistory(final IResource rsrc, final int flags,
>> final IProgressMonitor monitor) {
>> resource = rsrc;
>> - walk = buildWalk(flags);
>> + walk = buildWalk(/*flags*/);
>> revisions = buildRevisions(monitor, flags);
>> }
>> - private KidWalk buildWalk(final int flags) {
>> + private KidWalk buildWalk(/*final int flags*/) {
> Can't we just drop the parameter completely and wipe every trace of it?
OK
>> final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
>> if (rm == null) {
>> Activator.logError("Git not attached to project "
>> diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> index 04130db..db5f20b 100644
>> --- a/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> +++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java
>> @@ -48,9 +48,9 @@
>> * a Git repository.
>> */
>> public class GitProjectData {
>> - private static final Map projectDataCache = new HashMap();
>> + private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
>>
>> - private static final Map repositoryCache = new HashMap();
>> + private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();
> Been thinking about doing this myself but always found something more interesting to do. Good.
Hope that we will have a generic version of SWT/JFace sometime. Because now I do not know how to handle an inter operation between generic collections and SWT, use SuppressWarning there maybe?
>> diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> index dcc53cd..4700510 100644
>> --- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> +++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
>> @@ -175,8 +175,9 @@ public void back(int delta) {
>> // space so this prunes our search more quickly.
>> //
>> ptr -= Constants.OBJECT_ID_LENGTH;
>> - while (raw[--ptr] != ' ')
>> - /* nothing */;
>> + while (raw[--ptr] != ' ') {
>> + /* nothing */
>> + }
> Not sure if this buys us anything. I wouldn't react if original code was either way, but
> changing it seems unnecessary.
With an old version I get "Empty control-flow statement" warning, I've checked org.eclipse.jdt.core.prefs file, there is:
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
^ permalink raw reply
* Re: git-branch --print-current
From: Shawn O. Pearce @ 2009-01-05 2:18 UTC (permalink / raw)
To: Junio C Hamano
Cc: demerphq, Karl Chen, Miklos Vajna, David Aguilar,
Git mailing list
In-Reply-To: <7v1vvitwio.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
> demerphq <demerphq@gmail.com> writes:
>
> > The version im using, from git version 1.6.0.4.724.ga0d3a produces the
> > following error:
> >
> > cut: ./HEAD: No such file or directory
> >
> > when in the .git/refs directory.
>
> Personally, I think you are nuts to be in .git/refs and want to use that
> information for anything useful, but if it is an easy enough fix, a patch
> would be useful.
I agree, its nuts to be there. But this also does show up in 1.6.1.
What's odd is the output of rev-parse --git-dir is wrong:
$ cd .git/refs
$ git rev-parse --git-dir
.
Its *not* ".", its "..", I'm *in* the directory. This throws off
a lot of the other operations we do in __git_ps1, like detecting
the repository state by checking MERGE_HEAD or rebase-apply.
I think we should fix rev-parse --git-dir if we can, not the bash
completion code.
--
Shawn.
^ permalink raw reply
* Re: [EGIT PATCH] Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.
From: Shawn O. Pearce @ 2009-01-05 2:19 UTC (permalink / raw)
To: Vasyl' Vavrychuk; +Cc: git
In-Reply-To: <gjrgip$al9$1@ger.gmane.org>
Vasyl' Vavrychuk <vvavrychuk@gmail.com> wrote:
> Not sure what is right:
> public abstract class AnyObjectId implements Comparable<ObjectId> {
> or
> public abstract class AnyObjectId implements Comparable<AnyObjectId> {
>
> IMHO second, but class AnyObjectId contains some compareTo(ObjectId).
Hmmph. That probably can be AnyObjectId. At one point we only had
ObjectId, then AnyObjectId was introduced as a base so we can have
the immutable AnyObjectId and the mutable MutableObjectId subclasses.
compareTo doesn't care about the mutable state of its argument, this
is probably left-over code that didn't get converted when we added
the AnyObjectId base class.
So it should be the second, and the compareTo method should be made
to match that.
--
Shawn.
^ permalink raw reply
* configure clobbers LDFLAGS
From: Paul Jarc @ 2009-01-05 2:27 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 152 bytes --]
(I'm not subscribed; Mail-Followup-To set.)
In a couple of tests, configure clobbers the LDFLAGS value set by the
caller. This patch fixes it.
paul
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: git-ldflags.diff --]
[-- Type: text/x-patch, Size: 813 bytes --]
diff --git a/configure.ac b/configure.ac
index 8821b50..0a5fc8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,7 +127,7 @@ else
SAVE_LDFLAGS="${LDFLAGS}"
LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [ld_wl_rpath=yes], [ld_wl_rpath=no])
- LDFLAGS="${SAVE_LD_FLAGS}"
+ LDFLAGS="${SAVE_LDFLAGS}"
])
if test "$ld_wl_rpath" = "yes"; then
AC_SUBST(CC_LD_DYNPATH, [-Wl,-rpath,])
@@ -136,7 +136,7 @@ else
SAVE_LDFLAGS="${LDFLAGS}"
LDFLAGS="${SAVE_LDFLAGS} -rpath /"
AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [ld_rpath=yes], [ld_rpath=no])
- LDFLAGS="${SAVE_LD_FLAGS}"
+ LDFLAGS="${SAVE_LDFLAGS}"
])
if test "$ld_rpath" = "yes"; then
AC_SUBST(CC_LD_DYNPATH, [-rpath])
^ permalink raw reply related
* [PATCH] Permit a wider range of repository names in jgit daemon requests
From: Shawn O. Pearce @ 2009-01-05 2:46 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <200901040048.01520.robin.rosenberg@dewire.com>
The earlier restriction was too narrow for some applications, for
example repositories named "jgit.dev" and "jgit.test" are perfectly
valid Git repositories and should still be able to be served by
the daemon.
By blocking out only uses of ".." as a path component and Windows
UNC paths (by blocking "\") we can reasonably prevent the client
from escaping the base dirctories configured in the daemon.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> tisdag 23 december 2008 01:27:23 skrev Shawn O. Pearce:
> > + private static final Pattern SAFE_REPOSITORY_NAME = Pattern
> > + .compile("^[A-Za-z][A-Za-z0-9/_ -]+(\\.git)?$");
>
> This restriction is too strict. Wouldn't any path not containing ".." be valid? In particular this did not work with my "EGIT.contrib" repo. I
> have a lot of repos with names llike "name.purpose". Just adding
> '.' to the character set isn't really enough.
Yup.
.../src/org/spearce/jgit/transport/Daemon.java | 42 +++++++++----------
1 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
index 646c88d..d39fd04 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
@@ -51,7 +51,6 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import java.util.regex.Pattern;
import org.spearce.jgit.lib.Repository;
@@ -62,9 +61,6 @@
private static final int BACKLOG = 5;
- private static final Pattern SAFE_REPOSITORY_NAME = Pattern
- .compile("^[A-Za-z][A-Za-z0-9/_ -]+(\\.git)?$");
-
private InetSocketAddress myAddress;
private final DaemonService[] services;
@@ -292,24 +288,26 @@ synchronized (exports) {
return db;
}
- if (SAFE_REPOSITORY_NAME.matcher(name).matches()) {
- final File[] search;
- synchronized (exportBase) {
- search = exportBase.toArray(new File[exportBase.size()]);
- }
- for (final File f : search) {
- db = openRepository(new File(f, name));
- if (db != null)
- return db;
-
- db = openRepository(new File(f, name + ".git"));
- if (db != null)
- return db;
-
- db = openRepository(new File(f, name + "/.git"));
- if (db != null)
- return db;
- }
+ if (name.startsWith("../") || name.contains("/../")
+ || name.contains("\\"))
+ return null;
+
+ final File[] search;
+ synchronized (exportBase) {
+ search = exportBase.toArray(new File[exportBase.size()]);
+ }
+ for (final File f : search) {
+ db = openRepository(new File(f, name));
+ if (db != null)
+ return db;
+
+ db = openRepository(new File(f, name + ".git"));
+ if (db != null)
+ return db;
+
+ db = openRepository(new File(f, name + "/.git"));
+ if (db != null)
+ return db;
}
return null;
}
--
1.6.1.94.g9388
--
Shawn.
^ permalink raw reply related
* Re: git-branch --print-current
From: Junio C Hamano @ 2009-01-05 3:55 UTC (permalink / raw)
To: Shawn O. Pearce
Cc: demerphq, Karl Chen, Miklos Vajna, David Aguilar,
Git mailing list
In-Reply-To: <20090105021832.GA20973@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Junio C Hamano <gitster@pobox.com> wrote:
>> demerphq <demerphq@gmail.com> writes:
>>
>> > The version im using, from git version 1.6.0.4.724.ga0d3a produces the
>> > following error:
>> >
>> > cut: ./HEAD: No such file or directory
>> >
>> > when in the .git/refs directory.
>>
>> Personally, I think you are nuts to be in .git/refs and want to use that
>> information for anything useful, but if it is an easy enough fix, a patch
>> would be useful.
>
> I agree, its nuts to be there. But this also does show up in 1.6.1.
> What's odd is the output of rev-parse --git-dir is wrong:
>
> $ cd .git/refs
> $ git rev-parse --git-dir
> .
>
> Its *not* ".", its "..", I'm *in* the directory. This throws off
> a lot of the other operations we do in __git_ps1, like detecting
> the repository state by checking MERGE_HEAD or rebase-apply.
>
> I think we should fix rev-parse --git-dir if we can, not the bash
> completion code.
Sigh, yeah, that is what I thought would be happening.
^ permalink raw reply
* Re: git has modified files after clean checkout
From: Caleb Cushing @ 2009-01-05 5:11 UTC (permalink / raw)
To: Thomas Rast; +Cc: David Aguilar, git
In-Reply-To: <81bfc67a0901012149u23c8c9avb6f47817a56750c7@mail.gmail.com>
testing 1.6.1 release (not head) and still see the issue. right now
I'm assuming disabling autocrlf = input would help. regardless is this
behavior a bug or anticipated?
--
Caleb Cushing
http://xenoterracide.blogspot.com
^ permalink raw reply
* Re: git-rev-parse --symbolic-abbrev-name
From: Arnaud Lacombe @ 2009-01-05 5:35 UTC (permalink / raw)
To: Miklos Vajna; +Cc: Junio C Hamano, Karl Chen, David Aguilar, Git mailing list
In-Reply-To: <20090104223819.GI21154@genesis.frugalware.org>
Hi,
On Sun, Jan 4, 2009 at 5:38 PM, Miklos Vajna <vmiklos@frugalware.org> wrote:
> On Sun, Jan 04, 2009 at 03:23:03PM -0500, Arnaud Lacombe <lacombar@gmail.com> wrote:
>> ps: I choose --symbolic-short-name as the opposite of
>> --symbolic-full-name for consistency.
>> ps2: sorry for the bogus mime-type
>
> That's not a problem, just don't attach your patch. Please read
> Documentation/SubmittingPatches.
>
ok, looks, I did these patch this morning quickly, didn't commit
anything or so. If there worth anything, then I'll spent time
commiting, doing nice integration, documentation, whatsoever ... Just
need a quick yes or no, these as patch are really trivial.
- Arnaud
ps: btw, Documentation/git-format-patch.txt does not describe the -M
flag, not does it describe the -B flag
^ permalink raw reply
* Re: git-branch --print-current
From: Jeff King @ 2009-01-05 5:50 UTC (permalink / raw)
To: Junio C Hamano
Cc: Shawn O. Pearce, demerphq, Karl Chen, Miklos Vajna, David Aguilar,
Git mailing list
In-Reply-To: <7vsknys8y1.fsf@gitster.siamese.dyndns.org>
On Sun, Jan 04, 2009 at 07:55:34PM -0800, Junio C Hamano wrote:
> > I agree, its nuts to be there. But this also does show up in 1.6.1.
> > What's odd is the output of rev-parse --git-dir is wrong:
> >
> > $ cd .git/refs
> > $ git rev-parse --git-dir
> > .
> >
> > Its *not* ".", its "..", I'm *in* the directory. This throws off
> > a lot of the other operations we do in __git_ps1, like detecting
> > the repository state by checking MERGE_HEAD or rebase-apply.
> >
> > I think we should fix rev-parse --git-dir if we can, not the bash
> > completion code.
>
> Sigh, yeah, that is what I thought would be happening.
I took a quick look at this. I think there is something fundamentally
wrong with the logic for reporting relative git-dir. It basically ends
up doing something like (this is in setup_git_directory_gently, but the
value is just printed directly in rev-parse):
while (1) {
if (is_git_dir(".")) {
setenv("GIT_DIR", ".");
break;
}
chdir("..");
}
So yes, it's true at the end of that loop that we the git dir _is_ ".",
but that isn't suitable for telling any other processes who didn't
follow the chdir with us.
The quick fix is for rev-parse to turn that into an absolute path. I
don't know if that breaks any callers.
A better fix is probably for setup_git_directory to not require changing
the directory (or to chdir back to the original at the end, and set the
GIT_DIR in a properly relative manner).
-Peff
^ permalink raw reply
* Re: configure clobbers LDFLAGS
From: Jeff King @ 2009-01-05 6:00 UTC (permalink / raw)
To: prj; +Cc: Junio C Hamano, git
In-Reply-To: <m3tz8e32ru.fsf@multivac.cwru.edu>
On Sun, Jan 04, 2009 at 09:27:41PM -0500, Paul Jarc wrote:
> In a couple of tests, configure clobbers the LDFLAGS value set by the
> caller. This patch fixes it.
Thanks for the patch. It looks obviously correct to me, and the problem
was just some typos introduced by 798a9450.
Junio, I think this should go onto maint.
> (I'm not subscribed; Mail-Followup-To set.)
The usual behavior on this list is to reply to the sender, cc'ing the
list and any previous to or cc's. So MFT is unnecessary and generally
frowned upon here.
Also, if you are planning on sending more patches, the usual practice is
for them to be inline rather than attached, with the commit message as
the body and any cover letter (like MFT discussion) after the
triple-dash; git format-patch will generate this format for you. More
information is in Documentation/SubmittingPatches.
-Peff
^ permalink raw reply
* http push to WebDAV server fails (apache 2.2 under Win) - possible bug!?
From: Harald Weppner @ 2009-01-05 6:26 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 5232 bytes --]
Hi there,
just trying to get started to host a remote repository on a WebDAV
share (served by apache2.2 on Windows). When I attempt to push from my
local repository it indicates a 405 failure on a PUT of a
*opaquelocktoken:* resource (cf. apache access log below). I don't
know WebDAV in detail to know what's going wrong here but the colon in
the resource name looks suspicious as it's not a permitted character
under Windows. Could this indeed be a problem of not escaping the
resource name properly?
Thanks & cheerio, Harry.
> git push -v origin master
Pushing to http://user@example.com/webdav/repos/example.git/
Fetching remote heads...
refs/
refs/heads/
refs/tags/
updating 'refs/heads/master'
from 0000000000000000000000000000000000000000
to d310d475c459f7440a9a4ab8ae518f3a91011eb2
sending 12 objects
PUT 9d68391c5426d3b3c69a6b4c43c1110d13a710d5 failed, aborting (22/405)
PUT 57964966cd88e6a3a61c46ed4b186f26d5133dab failed, aborting (22/405)
PUT 7e03ccd9dcbb5a2770cc5e52aa168a97897ce01b failed, aborting (22/405)
PUT 67d59f8095ad0b5d90b50b05634038c831871f05 failed, aborting (22/405)
PUT 726f7925fa8539c202558d1cf7567c173fed6b42 failed, aborting (22/405)
error: failed to push some refs to 'http://user@example.com/webdav/repos/example.git/'
Here's how the apache error log looks like
[Sun Jan 04 21:51:27 2009] [error] [client xxx.xxx.xx.xxx] File does
not exist: C:/xampp/webdav/repos/example.git/info/refs
[Sun Jan 04 21:51:27 2009] [error] [client xxx.xxx.xx.xxx] File does
not exist: C:/xampp/webdav/repos/example.git/objects/info/packs
and this is apache's access log (showing the 405 errors)
[04/Jan/2009:21:51:26 -0800] "PROPFIND /webdav/repos/example.git/ HTTP/
1.1" 207 588 "-" "git/1.6.1"
[04/Jan/2009:21:51:27 -0800] "HEAD /webdav/repos/example.git/info/refs
HTTP/1.1" 404 - "-" "git/1.6.1"
[04/Jan/2009:21:51:27 -0800] "HEAD /webdav/repos/example.git/objects/
info/packs HTTP/1.1" 404 - "-" "git/1.6.1"
[04/Jan/2009:21:51:27 -0800] "PROPFIND /webdav/repos/example.git/refs/
HTTP/1.1" 207 2637 "-" "git/1.6.1"
[04/Jan/2009:21:51:27 -0800] "PROPFIND /webdav/repos/example.git/refs/
heads/ HTTP/1.1" 207 950 "-" "git/1.6.1"
[04/Jan/2009:21:51:27 -0800] "PROPFIND /webdav/repos/example.git/refs/
tags/ HTTP/1.1" 207 950 "-" "git/1.6.1"
[04/Jan/2009:21:51:27 -0800] "MKCOL /webdav/repos/example.git/refs
HTTP/1.1" 301 433 "-" "git/1.6.1"
[04/Jan/2009:21:51:28 -0800] "MKCOL /webdav/repos/example.git/refs/
HTTP/1.1" 405 1060 "-" "git/1.6.1"
[04/Jan/2009:21:51:28 -0800] "MKCOL /webdav/repos/example.git/refs/
heads HTTP/1.1" 301 439 "-" "git/1.6.1"
[04/Jan/2009:21:51:28 -0800] "MKCOL /webdav/repos/example.git/refs/
heads/ HTTP/1.1" 405 1060 "-" "git/1.6.1"
[04/Jan/2009:21:51:28 -0800] "LOCK /webdav/repos/example.git/refs/
heads/master HTTP/1.1" 200 471 "-" "git/1.6.1"
[04/Jan/2009:21:51:28 -0800] "PROPFIND /webdav/repos/example.git/
objects/d3/ HTTP/1.1" 404 1138 "-" "git/1.6.1"
[04/Jan/2009:21:51:28 -0800] "PROPFIND /webdav/repos/example.git/
objects/24/ HTTP/1.1" 404 1138 "-" "git/1.6.1"
[04/Jan/2009:21:51:28 -0800] "PROPFIND /webdav/repos/example.git/
objects/62/ HTTP/1.1" 404 1138 "-" "git/1.6.1"
[04/Jan/2009:21:51:28 -0800] "PROPFIND /webdav/repos/example.git/
objects/ca/ HTTP/1.1" 207 950 "-" "git/1.6.1"
[04/Jan/2009:21:51:28 -0800] "PROPFIND /webdav/repos/example.git/
objects/9c/ HTTP/1.1" 404 1138 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PROPFIND /webdav/repos/example.git/
objects/7e/ HTTP/1.1" 207 950 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PROPFIND /webdav/repos/example.git/
objects/6f/ HTTP/1.1" 404 1138 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PROPFIND /webdav/repos/example.git/
objects/72/ HTTP/1.1" 207 950 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PROPFIND /webdav/repos/example.git/
objects/67/ HTTP/1.1" 207 950 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PROPFIND /webdav/repos/example.git/
objects/57/ HTTP/1.1" 207 951 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PROPFIND /webdav/repos/example.git/
objects/9d/ HTTP/1.1" 207 950 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PUT /webdav/repos/example.git/objects/9d/
68391c5426d3b3c69a6b4c43c1110d13a710d5_opaquelocktoken:
35019a69-7377-2545-a7fa-0f7888f6e3bc HTTP/1.1" 405 1058 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PUT /webdav/repos/example.git/objects/
57/964966cd88e6a3a61c46ed4b186f26d5133dab_opaquelocktoken:
35019a69-7377-2545-a7fa-0f7888f6e3bc HTTP/1.1" 405 1058 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PUT /webdav/repos/example.git/objects/7e/
03ccd9dcbb5a2770cc5e52aa168a97897ce01b_opaquelocktoken:
35019a69-7377-2545-a7fa-0f7888f6e3bc HTTP/1.1" 405 1058 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PUT /webdav/repos/example.git/objects/67/
d59f8095ad0b5d90b50b05634038c831871f05_opaquelocktoken:
35019a69-7377-2545-a7fa-0f7888f6e3bc HTTP/1.1" 405 1058 "-" "git/1.6.1"
[04/Jan/2009:21:51:29 -0800] "PUT /webdav/repos/example.git/objects/
72/6f7925fa8539c202558d1cf7567c173fed6b42_opaquelocktoken:
35019a69-7377-2545-a7fa-0f7888f6e3bc HTTP/1.1" 405 1058 "-" "git/1.6.1"
[04/Jan/2009:21:51:30 -0800] "UNLOCK /webdav/repos/example.git/refs/
heads/master HTTP/1.1" 204 - "-" "git/1.6.1"
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2425 bytes --]
^ permalink raw reply
* Re: announce: TortoiseGit 0.2 preview released
From: Ping Yin @ 2009-01-05 6:40 UTC (permalink / raw)
To: Frank Li; +Cc: git, tortoisegit-announce
In-Reply-To: <1976ea660901040715l36667c7dld5f686e8c3624d1b@mail.gmail.com>
Wonderful work! Thanks.
On Sun, Jan 4, 2009 at 11:15 PM, Frank Li <lznuaa@gmail.com> wrote:
> After heavy developing, TortoiseGit 0.2 preview release published.
> TortoiseGit 0.2 can finish regular work, such as commit, show log,
> diff version, create tag, create branch, create patchs.
>
> Download:
> http://code.google.com/p/tortoisegit/downloads/list
>
> Version 0.2.0.0 preview version:
> Features:
> 1. Add TortoisgeMerge as default compare tools
> 2. Pull, Fetch, Push
> 3. Create Branch\Tag
> 4. Switch branch \Chechout
> 5. Compare with previous version
> 6. Clone(only support local repository, see known issue for detail)
> 7. Log Dialog support filter
> 8. Check for modifications
> 9. Revert local change
> 10.Create Patch Serial
> 11.Apply Patch Serial
> 12.Add file to repository(see know issue)
> 13.Export to zip file
>
> Bug Fix:
> 1. A2W cause stack overwrite bug when git output is long.
>
>
> Known Issue:
> 1. ProcessDlg will wait for ever when clone remote repository(ssh, http,git).
> 2. push fetch and pull don't support password mode. Just support
> public key problem.
> 3. Just fetch first 100 log item.
> 4. If install TortoiseGit before MsysGit, you need modify register
> HKEY_LOCAL_MACHINE\Software\TortoiseGit\\MsysGit\
> Let it point to correct msysgit install path.
> 5. Add File, please commit and show unversion file, the choose add
> file, then right clict, Choose Add file
> 6. To new initial repository, You will not see add file again in
> commit dialog box if give up commit when choose add
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: git-rev-parse --symbolic-abbrev-name
From: Miklos Vajna @ 2009-01-05 6:45 UTC (permalink / raw)
To: Arnaud Lacombe; +Cc: Junio C Hamano, Karl Chen, David Aguilar, Git mailing list
In-Reply-To: <1a69a9d80901042135w5f1c4aa2jd56ff1d9e4ffd38a@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 274 bytes --]
On Mon, Jan 05, 2009 at 12:35:23AM -0500, Arnaud Lacombe <lacombar@gmail.com> wrote:
> ps: btw, Documentation/git-format-patch.txt does not describe the -M
> flag, not does it describe the -B flag
But has a 'include::diff-options.txt[]', so the generated manpage does.
;-)
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: [EGIT PATCH] Sorting commit items by click on the table header in commit dialog.
From: Robin Rosenberg @ 2009-01-05 7:35 UTC (permalink / raw)
To: Vasyl' Vavrychuk, Shawn O. Pearce; +Cc: git
In-Reply-To: <gjre95$4cs$1@ger.gmane.org>
söndag 04 januari 2009 23:46:47 skrev Vasyl' Vavrychuk:
> In order to implement new feature I have replaced class associated with every table row.
> CommitItem class encapsulate data that commit dialog manipulates with.
> Comparators are written using idiom from http://tobega.blogspot.com/2008/05/beautiful-enums.html.
> Clicks on a certain column are handled in HeaderSelectionListener class.
Hmm. This one cannot be applied on top of master. There is only only one commit on Dec 8
that involves the same file, so If you could rebase that would be nice. Other than that it looks ok.
Please also Cc me and Shawn on patches to reduce the risk of them getting lost.
-- robin
^ permalink raw reply
* [PATCH] Fix sourcing "test-lib.sh" using dash shell in "t3003-ls-files-narrow-match.sh"
From: Christian Couder @ 2009-01-05 13:30 UTC (permalink / raw)
To: Junio C Hamano, Nguyen Thai Ngoc Duy; +Cc: git
dash barfs, on my old Ubuntu box, when "test-lib.sh" is sourced
without "./".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
t/t3003-ls-files-narrow-match.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
This patch applies to "pu".
diff --git a/t/t3003-ls-files-narrow-match.sh b/t/t3003-ls-files-narrow-match.sh
index 9879525..b576bca 100755
--- a/t/t3003-ls-files-narrow-match.sh
+++ b/t/t3003-ls-files-narrow-match.sh
@@ -2,7 +2,7 @@
test_description='This test is for narrow spec matching'
-. test-lib.sh
+. ./test-lib.sh
D="$(cd ..;pwd)"/t3003
--
1.6.1.143.gfd590.dirty
^ permalink raw reply related
* [PATCH/RFC 0/4] git checkout: optimise away lots of lstat() calls
From: Kjetil Barvik @ 2009-01-05 13:09 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds, Junio C Hamano, Kjetil Barvik
I have just started to clone some interesting Linux git trees to watch
the development more closely, and therefore also started to use git. I
noticed that 'git checkout' takes some time, and especially that the
'git checkout' command does lots and lots of lstat() calls.
After some more investigation and thinking, I have made 4 patches and
been able to optimise away over 42% of all lstat() calls in some cases
for the 'git checkout' command. I have not tested other git porcelain
commands for reduced lstat() calls, but I would guess that the more
effective 'lstat_cache()' compared to 'has_leading_symlink_cache()',
should also give better numbers in other cases.
All the 4 patches is against git master, and the git 'make test'
test suite still passes after each patch.
To document the improvement, below is some numbers, which compares
before and after all 4 patches. To reproduce the numbers:
- git clone the Linux git tree to be able to get the Linux tags
'v2.6.25' and 'v2.6.27'.
- git checkout -b my-v2.6.27 v2.6.27
- git checkout -b my-v2.6.25 v2.6.25
Then, when the current branch is 'my-v2.6.25' do:
strace -o strace_to27 -T git checkout -q my-v2.6.27
And then you pretty print and collect stats from the 'strace_to27'
file. If someone wants a copy of the strace_stat.pl script, which I
made/used to do the pretty printing, then give me a hint.
Below is the stats/numbers from the current git version (before the 4
patches). Notice that we do an lstat() call on the "arch" directory
over 6000 times!
TOTAL 185151 100.000% OK:165544 NOT: 19607 11.136001 sec 60 usec/call
lstat64 120954 65.327% OK:107013 NOT: 13941 5.388727 sec 45 usec/call
strings 120954 tot 30163 uniq 4.010 /uniq 5.388727 sec 45 usec/call
files 61491 tot 28712 uniq 2.142 /uniq 2.740520 sec 45 usec/call
dirs 45522 tot 1436 uniq 31.701 /uniq 1.994448 sec 44 usec/call
errors 13941 tot 5189 uniq 2.687 /uniq 0.653759 sec 47 usec/call
6297 5.206% OK: 6297 NOT: 0 "arch"
4544 3.757% OK: 4544 NOT: 0 "drivers"
1816 1.501% OK: 1816 NOT: 0 "arch/arm"
1499 1.239% OK: 1499 NOT: 0 "include"
912 0.754% OK: 912 NOT: 0 "arch/powerpc"
764 0.632% OK: 764 NOT: 0 "fs"
746 0.617% OK: 746 NOT: 0 "drivers/net"
662 0.547% OK: 662 NOT: 0 "net"
652 0.539% OK: 325 NOT: 327 "arch/sparc/include"
636 0.526% OK: 636 NOT: 0 "drivers/media"
606 0.501% OK: 606 NOT: 0 "include/linux"
533 0.441% OK: 533 NOT: 0 "arch/sh"
522 0.432% OK: 260 NOT: 262 "arch/powerpc/include"
488 0.403% OK: 243 NOT: 245 "arch/sh/include"
413 0.341% OK: 413 NOT: 0 "arch/sparc"
390 0.322% OK: 390 NOT: 0 "arch/x86"
383 0.317% OK: 383 NOT: 0 "Documentation"
370 0.306% OK: 184 NOT: 186 "arch/ia64/include"
366 0.303% OK: 366 NOT: 0 "drivers/media/video"
348 0.288% OK: 173 NOT: 175 "arch/arm/include"
Here is the stats/numbers after applying the 4 patches. Notice how
nice the top 20 entries list now looks!
TOTAL 133655 100.000% OK:121615 NOT: 12040 10.429999 sec 78 usec/call
lstat64 69603 52.077% OK: 63218 NOT: 6385 3.419920 sec 49 usec/call
strings 69603 tot 30163 uniq 2.308 /uniq 3.419920 sec 49 usec/call
files 61491 tot 28712 uniq 2.142 /uniq 3.034869 sec 49 usec/call
dirs 1727 tot 1164 uniq 1.484 /uniq 0.075681 sec 44 usec/call
errors 6385 tot 5189 uniq 1.230 /uniq 0.309370 sec 48 usec/call
4 0.006% OK: 4 NOT: 0 ".gitignore"
4 0.006% OK: 4 NOT: 0 ".mailmap"
4 0.006% OK: 4 NOT: 0 "CREDITS"
4 0.006% OK: 4 NOT: 0 "Documentation/00-INDEX"
4 0.006% OK: 4 NOT: 0 "Documentation/ABI/testing/sysfs-block"
4 0.006% OK: 4 NOT: 0 "Documentation/ABI/testing/sysfs-firmware-acpi"
4 0.006% OK: 4 NOT: 0 "Documentation/CodingStyle"
4 0.006% OK: 4 NOT: 0 "Documentation/DMA-API.txt"
4 0.006% OK: 4 NOT: 0 "Documentation/DMA-mapping.txt"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/Makefile"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/gadget.tmpl"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/kernel-api.tmpl"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/kernel-locking.tmpl"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/procfs-guide.tmpl"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/procfs_example.c"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/rapidio.tmpl"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/s390-drivers.tmpl"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/uio-howto.tmpl"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/videobook.tmpl"
4 0.006% OK: 4 NOT: 0 "Documentation/DocBook/writing_usb_driver.tmpl"
Note that the overall used system time as recorded from 'strace -T',
does not drop so much that the reduced lstat() time should indicate
for _this_ particular test run. This is because now each unlink()
call takes much more time, at least for me on an slow ide disk (using
ext3) on a laptop.
A simple test gives me an overall improvement of 2.937 seconds: real
time drops from 28.195s (best of 5 runs with 'time git ...'), to
25.381s (best of 5 runs).
Comments?
Kjetil Barvik (4):
Optimised, faster, more effective symlink/directory detection
Use 'lstat_cache()' instead of 'has_symlink_leading_path()'
create_directories() inside entry.c: only check each directory once!
remove the old 'has_symlink_leading_path()' function
Makefile | 2 +-
builtin-add.c | 5 ++-
builtin-apply.c | 5 ++-
builtin-update-index.c | 5 ++-
cache.h | 17 +++++++-
diff-lib.c | 5 ++-
dir.c | 4 +-
entry.c | 86 +++++++++++++++++++++++++++++++--------
lstat_cache.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++
symlinks.c | 64 -----------------------------
unpack-trees.c | 10 ++++-
11 files changed, 217 insertions(+), 91 deletions(-)
create mode 100644 lstat_cache.c
delete mode 100644 symlinks.c
^ permalink raw reply
* [PATCH/RFC 1/4] Optimised, faster, more effective symlink/directory detection
From: Kjetil Barvik @ 2009-01-05 13:09 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds, Junio C Hamano, Kjetil Barvik
In-Reply-To: <1231161001-32599-1-git-send-email-barvik@broadpark.no>
This patch is work based on the following 2 commits:
Linus Torvalds: c40641b77b0274186fd1b327d5dc3246f814aaaf
Junio C Hamano: f859c846e90b385c7ef873df22403529208ade50
Changes includes the following:
- The cache functionality is more effective. Previously when A/B/C/D
was in the cache and A/B/C/E/file.c was called for, there was no
match at all from the cache. Now we use the fact that the paths
"A", "A/B" and "A/B/C" is already tested, and we only need to do an
lstat() call on "A/B/C/E".
- We only cache/store the last path regardless of it's type. Since the
cache functionality is always used with alphabetically sorted names
(at least it seams so for me), there is no need to store both the
last symlink-leading path and the last real-directory path. Note
that if the cache is not called with (mostly) alphabetically sorted
names, neither the old, nor this new one, would be very effective.
- We also can cache the fact that a directory does not exist.
Previously we could end up doing lots of lstat() calls for a removed
directory which previously contained lots of files. Since we
already have simplified the cache functionality and only store the
last path (see above), this new functionality was easy to add.
- Avoid copying the first path components of the name 2 zillions times
when we tests new path components. Since we always cache/store the
last path, we can copy each component as we test those directly into
the cache. Previously we ended up doing a memcpy() for the full
path/name right before each lstat() call, and when updating the
cache for each time we have tested an new path component.
- We also use less memory, that is PATH_MAX bytes less memory on the
stack and PATH_MAX bytes less memory on the heap.
- Introduce a 3rd argument, 'unsigned int track_flags', to the
cache-test function, check_lstat_cache(). This new argument can be
used to tell the cache functionality which types of directories
should be cached.
- Also introduce a 'void clear_lstat_cache(void)' function, which
should be used to clean the cache before usage. If for instance,
you have changed the types of directories which should be cached,
the cache could contain a path which was not wanted.
Signed-off-by: Kjetil Barvik <barvik@broadpark.no>
---
:100644 100644 aabf013... 7449b10... M Makefile
:100644 100644 231c06d... 7c246a4... M cache.h
:000000 100644 0000000... 34f4e9a... A lstat_cache.c
Makefile | 1 +
cache.h | 15 ++++++++
lstat_cache.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 121 insertions(+), 0 deletions(-)
create mode 100644 lstat_cache.c
diff --git a/Makefile b/Makefile
index aabf0130b99bee5204c8e668ba8f40caea77dae2..7449b105b03e862d53244d50ed035b4ddabef028 100644
--- a/Makefile
+++ b/Makefile
@@ -446,6 +446,7 @@ LIB_OBJS += list-objects.o
LIB_OBJS += ll-merge.o
LIB_OBJS += lockfile.o
LIB_OBJS += log-tree.o
+LIB_OBJS += lstat_cache.o
LIB_OBJS += mailmap.o
LIB_OBJS += match-trees.o
LIB_OBJS += merge-file.o
diff --git a/cache.h b/cache.h
index 231c06d7726b575f6e522d5b0c0fe43557e8c651..7c246a42df3d60ac2c0f7431ff29ee8fb70235ce 100644
--- a/cache.h
+++ b/cache.h
@@ -721,6 +721,21 @@ struct checkout {
extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath);
extern int has_symlink_leading_path(int len, const char *name);
+#define LSTAT_DIR (1u << 0)
+#define LSTAT_NOTDIR (1u << 1)
+#define LSTAT_SYMLINK (1u << 2)
+#define LSTAT_LSTATERR (1u << 3)
+#define LSTAT_ERR (1u << 4)
+extern unsigned int check_lstat_cache(int len, const char *name,
+ unsigned int track_flags);
+static inline unsigned int lstat_cache(int len, const char *name,
+ unsigned int track_flags,
+ unsigned int mask_flags)
+{
+ return check_lstat_cache(len, name, track_flags) & mask_flags;
+}
+extern void clear_lstat_cache(void);
+
extern struct alternate_object_database {
struct alternate_object_database *next;
char *name;
diff --git a/lstat_cache.c b/lstat_cache.c
new file mode 100644
index 0000000000000000000000000000000000000000..34f4e9a003905323f45a4f739d2a354e02dbbe93
--- /dev/null
+++ b/lstat_cache.c
@@ -0,0 +1,105 @@
+#include "cache.h"
+
+static char cache_path[PATH_MAX];
+static int cache_len = 0;
+static unsigned int cache_flags = 0;
+
+static inline int
+greatest_common_path_cache_prefix(int len, const char *name)
+{
+ int max_len, match_len = 0, i = 0;
+
+ max_len = len < cache_len ? len : cache_len;
+ while (i < max_len && name[i] == cache_path[i]) {
+ if (name[i] == '/') match_len = i;
+ i++;
+ }
+ if (i == cache_len && len > cache_len && name[cache_len] == '/')
+ match_len = cache_len;
+ return match_len;
+}
+
+static inline void
+update_path_cache(unsigned int ret_flags, unsigned int track_flags,
+ int last_slash)
+{
+ /* Max 3 different path types can be cached for the moment! */
+ unsigned int save_flags =
+ ret_flags & track_flags & (LSTAT_DIR|
+ LSTAT_NOTDIR|
+ LSTAT_SYMLINK);
+ if (save_flags && last_slash > 0 && last_slash < PATH_MAX) {
+ cache_flags = save_flags;
+ cache_len = last_slash;
+ } else {
+ cache_flags = 0;
+ cache_len = 0;
+ }
+}
+
+/*
+ * Check if name 'name' of length 'len' has a symlink leading
+ * component, or if the directory exists and is real, or not.
+ *
+ * To speed up the check, some information is allowed to be cached.
+ * This is indicated by the 'track_flags' argument.
+ */
+unsigned int
+check_lstat_cache(int len, const char *name, unsigned int track_flags)
+{
+ int match_len, last_slash, max_len;
+ unsigned int match_flags, ret_flags;
+ struct stat st;
+
+ /* Check if match from the cache for 2 "excluding" path types.
+ */
+ match_len = last_slash =
+ greatest_common_path_cache_prefix(len, name);
+ match_flags =
+ cache_flags & track_flags & (LSTAT_NOTDIR|
+ LSTAT_SYMLINK);
+ if (match_flags && match_len == cache_len)
+ return match_flags;
+
+ /* Okay, no match from the cache so far, so now we have to
+ * check the rest of the path components and update the cache.
+ */
+ ret_flags = LSTAT_DIR;
+ max_len = len < PATH_MAX ? len : PATH_MAX;
+ while (match_len < max_len) {
+ do {
+ cache_path[match_len] = name[match_len];
+ match_len++;
+ } while (match_len < max_len && name[match_len] != '/');
+ if (match_len >= max_len)
+ break;
+ last_slash = match_len;
+ cache_path[last_slash] = '\0';
+
+ if (lstat(cache_path, &st)) {
+ ret_flags = LSTAT_LSTATERR;
+ if (errno == ENOENT || errno == ENOTDIR)
+ ret_flags |= LSTAT_NOTDIR;
+ } else if (S_ISDIR(st.st_mode)) {
+ continue;
+ } else if (S_ISLNK(st.st_mode)) {
+ ret_flags = LSTAT_SYMLINK;
+ } else {
+ ret_flags = LSTAT_ERR;
+ }
+ break;
+ }
+ update_path_cache(ret_flags, track_flags, last_slash);
+ return ret_flags;
+}
+
+/*
+ * Before usage of the check_lstat_cache() function one should call
+ * clear_lstat_cache() (at an appropriate place) to make sure that the
+ * cache is clean before first call to check_lstat_cache().
+ */
+void clear_lstat_cache(void)
+{
+ cache_flags = 0;
+ cache_len = 0;
+}
--
1.6.1.rc1.49.g7f705
^ permalink raw reply related
* [PATCH/RFC 2/4] Use 'lstat_cache()' instead of 'has_symlink_leading_path()'
From: Kjetil Barvik @ 2009-01-05 13:09 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds, Junio C Hamano, Kjetil Barvik
In-Reply-To: <1231161001-32599-1-git-send-email-barvik@broadpark.no>
Start using the optimised, faster and more effective symlink/directory
cache. The previously used call:
has_symlink_leading_path(len, name);
should be identically with the following call to lstat_cache():
lstat_cache(len, name,
LSTAT_SYMLINK|LSTAT_DIR,
LSTAT_SYMLINK);
The primary reason for the new name of the function (instead of using
the old name and add 2 extra arguments), is that it is now more
general, for instance, it now also can cache the fact that a directory
does not exists.
I noticed that inside the unlink_entry() function in unpack-trees.c,
one could often end up calling rmdir() lots and lots of times on
none-empty directories. Maybe one should schedule each directory for
removal by an appropriate function, and then at the end call a new
function to clean all the directories at once?
Signed-off-by: Kjetil Barvik <barvik@broadpark.no>
---
:100644 100644 719de8b... 152c52c... M builtin-add.c
:100644 100644 a8f75ed... 0eb2b21... M builtin-apply.c
:100644 100644 65d5775... fa7d994... M builtin-update-index.c
:100644 100644 ae96c64... 127bdf2... M diff-lib.c
:100644 100644 0131983... 9f2a1b1... M dir.c
:100644 100644 54f301d... 93923db... M unpack-trees.c
builtin-add.c | 5 ++++-
builtin-apply.c | 5 ++++-
builtin-update-index.c | 5 ++++-
diff-lib.c | 5 ++++-
dir.c | 4 +++-
unpack-trees.c | 9 +++++++--
6 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/builtin-add.c b/builtin-add.c
index 719de8b0f2d2d831f326d948aa18700e5c474950..152c52c0f22b3e71931b2a5629e1472602817785 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -121,7 +121,9 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
if (pathspec) {
const char **p;
for (p = pathspec; *p; p++) {
- if (has_symlink_leading_path(strlen(*p), *p)) {
+ if (lstat_cache(strlen(*p), *p,
+ LSTAT_SYMLINK|LSTAT_DIR,
+ LSTAT_SYMLINK)) {
int len = prefix ? strlen(prefix) : 0;
die("'%s' is beyond a symbolic link", *p + len);
}
@@ -225,6 +227,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, builtin_add_options,
builtin_add_usage, 0);
+ clear_lstat_cache();
if (patch_interactive)
add_interactive = 1;
if (add_interactive)
diff --git a/builtin-apply.c b/builtin-apply.c
index a8f75ed3ed411d8cf7a3ec9dfefef7407c50f447..0eb2b21ee245919189c780a64cc494ca35f7934a 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2354,7 +2354,9 @@ static int check_to_create_blob(const char *new_name, int ok_if_exists)
* In such a case, path "new_name" does not exist as
* far as git is concerned.
*/
- if (has_symlink_leading_path(strlen(new_name), new_name))
+ if (lstat_cache(strlen(new_name), new_name,
+ LSTAT_SYMLINK|LSTAT_DIR,
+ LSTAT_SYMLINK))
return 0;
return error("%s: already exists in working directory", new_name);
@@ -3154,6 +3156,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
if (apply_default_whitespace)
parse_whitespace_option(apply_default_whitespace);
+ clear_lstat_cache();
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
char *end;
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 65d5775107f9013526cc5b288a80a00b449e8814..fa7d994b3cfe7343c1a181f4c6f6a4c6ee6cea75 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -195,7 +195,9 @@ static int process_path(const char *path)
struct stat st;
len = strlen(path);
- if (has_symlink_leading_path(len, path))
+ if (lstat_cache(len, path,
+ LSTAT_SYMLINK|LSTAT_DIR,
+ LSTAT_SYMLINK))
return error("'%s' is beyond a symbolic link", path);
/*
@@ -581,6 +583,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
if (entries < 0)
die("cache corrupted");
+ clear_lstat_cache();
for (i = 1 ; i < argc; i++) {
const char *path = argv[i];
const char *p;
diff --git a/diff-lib.c b/diff-lib.c
index ae96c64ca209f4df9008198e8a04b160bed618c7..127bdf2dfbeb3538fa01e500ed8bcd3f4c8d422b 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -31,7 +31,9 @@ static int check_removed(const struct cache_entry *ce, struct stat *st)
return -1;
return 1;
}
- if (has_symlink_leading_path(ce_namelen(ce), ce->name))
+ if (lstat_cache(ce_namelen(ce), ce->name,
+ LSTAT_SYMLINK|LSTAT_NOTDIR|LSTAT_DIR,
+ LSTAT_SYMLINK))
return 1;
if (S_ISDIR(st->st_mode)) {
unsigned char sub[20];
@@ -69,6 +71,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
diff_unmerged_stage = 2;
entries = active_nr;
symcache[0] = '\0';
+ clear_lstat_cache();
for (i = 0; i < entries; i++) {
struct stat st;
unsigned int oldmode, newmode;
diff --git a/dir.c b/dir.c
index 0131983dfbc143ce5dae77e067663bb2e7d5f126..9f2a1b1f245c3f1d4f12d54d45bb193c53fa15b5 100644
--- a/dir.c
+++ b/dir.c
@@ -719,7 +719,9 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
{
struct path_simplify *simplify;
- if (has_symlink_leading_path(strlen(path), path))
+ if (lstat_cache(strlen(path), path,
+ LSTAT_SYMLINK|LSTAT_DIR,
+ LSTAT_SYMLINK))
return dir->nr;
simplify = create_simplify(pathspec);
diff --git a/unpack-trees.c b/unpack-trees.c
index 54f301da67be879c80426bc21776427fdd38c02e..93923dbbc6ab80deadfd737aa9975f6e5a4d1e89 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -61,7 +61,9 @@ static void unlink_entry(struct cache_entry *ce)
char *cp, *prev;
char *name = ce->name;
- if (has_symlink_leading_path(ce_namelen(ce), ce->name))
+ if (lstat_cache(ce_namelen(ce), ce->name,
+ LSTAT_SYMLINK|LSTAT_NOTDIR|LSTAT_DIR,
+ LSTAT_SYMLINK|LSTAT_NOTDIR))
return;
if (unlink(name))
return;
@@ -105,6 +107,7 @@ static int check_updates(struct unpack_trees_options *o)
cnt = 0;
}
+ clear_lstat_cache();
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
@@ -584,7 +587,9 @@ static int verify_absent(struct cache_entry *ce, const char *action,
if (o->index_only || o->reset || !o->update)
return 0;
- if (has_symlink_leading_path(ce_namelen(ce), ce->name))
+ if (lstat_cache(ce_namelen(ce), ce->name,
+ LSTAT_SYMLINK|LSTAT_NOTDIR|LSTAT_DIR,
+ LSTAT_SYMLINK|LSTAT_NOTDIR))
return 0;
if (!lstat(ce->name, &st)) {
--
1.6.1.rc1.49.g7f705
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox