threads / patch / 19206

patch, 2 partsUse NullProgressMonitor.INSTANCE and indent for loop

Subject: [PATCH 2/2] Use NullProgressMonitor.INSTANCE and indent for loop

## tl;dr

8 messages between May 6, 2009 and May 6, 2009. Diffs are folded; open one to read it.

replies: 7people: 3as markdown or json

Alex Blewitt· May 6, 2009, 20:37 UTC · lore

[PATCH 1/2] Allow monitor/unintersting objects to be null

---
 .../src/org/spearce/jgit/lib/PackWriter.java       |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Show changes to org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java +3 −2
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
index ea63942..3d7004d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
@@ -230,8 +230,8 @@ public PackWriter(final Repository repo, final ProgressMonitor monitor) {
 	public PackWriter(final Repository repo, final ProgressMonitor imonitor,
 			final ProgressMonitor wmonitor) {
 		this.db = repo;
-		initMonitor = imonitor;
-		writeMonitor = wmonitor;
+		initMonitor = (imonitor == null ? new NullProgressMonitor() : imonitor);
+		writeMonitor = (wmonitor == null ? new NullProgressMonitor() : wmonitor);
 		this.deflater = new Deflater(db.getConfig().getCore().getCompression());
 		outputVersion = repo.getConfig().getCore().getPackIndexVersion();
 	}
@@ -829,6 +829,7 @@ private ObjectWalk setUpWalker(
 			RevObject o = walker.parseAny(id);
 			walker.markStart(o);
 		}
+		if (uninterestingObjects != null)
 		for (ObjectId id : uninterestingObjects) {
 			final RevObject o;
 			try {
-- 
1.6.2.2
Alex Blewitt· May 6, 2009, 20:37 UTC · re: Alex Blewitt · lore
---
 .../src/org/spearce/jgit/lib/PackWriter.java       |   25 ++++++++++---------
 1 files changed, 13 insertions(+), 12 deletions(-)
Show changes to org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java +13 −12
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
index 3d7004d..a35f61d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
@@ -230,8 +230,8 @@ public PackWriter(final Repository repo, final ProgressMonitor monitor) {
 	public PackWriter(final Repository repo, final ProgressMonitor imonitor,
 			final ProgressMonitor wmonitor) {
 		this.db = repo;
-		initMonitor = (imonitor == null ? new NullProgressMonitor() : imonitor);
-		writeMonitor = (wmonitor == null ? new NullProgressMonitor() : wmonitor);
+		initMonitor = imonitor == null ? NullProgressMonitor.INSTANCE : imonitor;
+		writeMonitor = wmonitor == null ? NullProgressMonitor.INSTANCE : wmonitor;
 		this.deflater = new Deflater(db.getConfig().getCore().getCompression());
 		outputVersion = repo.getConfig().getCore().getPackIndexVersion();
 	}
@@ -829,17 +829,18 @@ private ObjectWalk setUpWalker(
 			RevObject o = walker.parseAny(id);
 			walker.markStart(o);
 		}
-		if (uninterestingObjects != null)
-		for (ObjectId id : uninterestingObjects) {
-			final RevObject o;
-			try {
-				o = walker.parseAny(id);
-			} catch (MissingObjectException x) {
-				if (ignoreMissingUninteresting)
-					continue;
-				throw x;
+		if (uninterestingObjects != null) {
+			for (ObjectId id : uninterestingObjects) {
+				final RevObject o;
+				try {
+					o = walker.parseAny(id);
+				} catch (MissingObjectException x) {
+					if (ignoreMissingUninteresting)
+						continue;
+					throw x;
+				}
+				walker.markUninteresting(o);
 			}
-			walker.markUninteresting(o);
 		}
 		return walker;
 	}
-- 
1.6.2.2
Shawn O. Pearce· May 6, 2009, 20:41 UTC · re: Alex Blewitt · lore

Re: [PATCH 2/2] Use NullProgressMonitor.INSTANCE and indent for loop

Alex Blewitt <alex.blewitt@gmail.com> wrote:
> ---
>  .../src/org/spearce/jgit/lib/PackWriter.java       |   25 ++++++++++---------
>  1 files changed, 13 insertions(+), 12 deletions(-)

Huh. These two should have been squashed together; see "git rebase -i HEAD~2" and its "squash" subcommand.

It looks fine otherwise. I'll squash here when I apply. Just keep it in mind for future reference.

-- 
Shawn.
Shawn O. Pearce· May 6, 2009, 20:48 UTC · re: Alex Blewitt · lore

Re: [PATCH 2/2] Use NullProgressMonitor.INSTANCE and indent for loop

Alex Blewitt <alex.blewitt@gmail.com> wrote:
> ---
>  .../src/org/spearce/jgit/lib/PackWriter.java       |   25 ++++++++++---------
>  1 files changed, 13 insertions(+), 12 deletions(-)

Also, I'd like a Signed-off-by line for your patches. We follow Linux kernel tradition and use a Signed-off-by line to mean you agree to the "Developer's Certificate of Origin 1.1" (see SUBMITTING_PATCHES in the top level directory, part 5).

For the 2 that you've submitted thus far (this one, and the make
private constructor) you can just reply to the email and drop the
SOB line into the message body.  In the future make sure you add
it in with git commit -s or git format-patch -s prior to sending.
 
-- 
Shawn.
Alex Blewitt· May 6, 2009, 20:50 UTC · re: Shawn O. Pearce · lore

Re: [PATCH 2/2] Use NullProgressMonitor.INSTANCE and indent for loop

I've been using git send-email --format-patch, which doesn't appear to add the signed by line. If I do it as the commit, will it add the signed-by when it gets committed, and thus I can use send-email? git format-patch just seems to dump a load of files into the directory, and (as noted elsewhere) the git-rebase doesn't appear to work for me.

Alex
On 6 May 2009, at 21:48, Shawn O. Pearce wrote:
Show 18 quoted lines
> Alex Blewitt <alex.blewitt@gmail.com> wrote:
>> ---
>> .../src/org/spearce/jgit/lib/PackWriter.java       |   25 +++++++++ 
>> +---------
>> 1 files changed, 13 insertions(+), 12 deletions(-)
>
> Also, I'd like a Signed-off-by line for your patches.  We follow
> Linux kernel tradition and use a Signed-off-by line to mean
> you agree to the "Developer's Certificate of Origin 1.1" (see
> SUBMITTING_PATCHES in the top level directory, part 5).
>
> For the 2 that you've submitted thus far (this one, and the make
> private constructor) you can just reply to the email and drop the
> SOB line into the message body.  In the future make sure you add
> it in with git commit -s or git format-patch -s prior to sending.
>
> -- 
> Shawn.
Shawn O. Pearce· May 6, 2009, 20:54 UTC · re: Alex Blewitt · lore

Re: [PATCH 2/2] Use NullProgressMonitor.INSTANCE and indent for loop

Alex Blewitt <alex.blewitt@gmail.com> wrote:
Show 5 quoted lines
> I've been using git send-email --format-patch, which doesn't appear to  
> add the signed by line. If I do it as the commit, will it add the  
> signed-by when it gets committed, and thus I can use send-email? git  
> format-patch just seems to dump a load of files into the directory, and 
> (as noted elsewhere) the git-rebase doesn't appear to work for me.

IIRC, "git send-email --format-patch -- -s" would pass -s to the format-patch script, adding the line automatically. But that's an undocumented feature of send-email.

Personally, I put the SOB line in with "git commit -s" when I write the change. Then its there when I dump it out with format-patch.

As for format-patch making a ton of files, yea, that's its job. I actually use the following pair of scripts to manage sending, as this lets me edit _sop/OUT/* before firing it off.

--8<--
#!/bin/sh
if [ -n "$(git rev-parse --show-cdup)" ]; then
	cd $(git rev-parse --show-cdup) || exit
fi
mkdir -p _sop/OUT &&
rm -f $(find _sop/OUT -name '*.patch' | grep -v '0000-cover-letter') &&
base="${1:-master}" &&
if [ $(git rev-list ^$base HEAD | wc -l) -gt 1 ]
then
	n="--numbered --cover-letter"
fi &&
git format-patch \
	--output-directory _sop/OUT \
	--subject-prefix='JGIT PATCH' \
	-M \
	$n \
	$base || exit
----
--8<--
#!/bin/sh
if [ -n "$(git rev-parse --show-cdup)" ]; then
	cd $(git rev-parse --show-cdup) || exit
fi

ls -1 _sop/OUT read

git send-email \
	--to 'Robin Rosenberg <robin.rosenberg@dewire.com>' \
	--cc 'git@vger.kernel.org' \
	--chain-reply-to \
	--suppress-cc self \
	--smtp-server localhost \
	--smtp-server-port 8025 \
	_sop/OUT
----
-- 
Shawn.
Robin Rosenberg· May 6, 2009, 21:10 UTC · re: Alex Blewitt · lore

Re: [PATCH 1/2] Allow monitor/unintersting objects to be null

Besides all comments by Shawn. Please set the prefix to EGIT PATCH or JGIT PATCH so the C Git people that are not interested in JGit know this isn't for them.

If you add this to your .git/config you will get the prefix automagically when generating the patches.

[format]
        subjectprefix = EGIT PATCH
-- robin
Alex Blewitt· May 6, 2009, 21:28 UTC · re: Robin Rosenberg · lore

Re: [PATCH 1/2] Allow monitor/unintersting objects to be null

Thanks Robin, that's great. I did attempt to set the subject on git send-mail --subject, but unfortunately it had no impact; note the 'Subject' on the line.

It works if I configure the .gitconfig though. I'll do that in the future.
apple:egit alex$ git send-email origin/master --subject "Fooooooooo" --dry-run
(mbox) Adding cc: Alex Blewitt <alex.blewitt@gmail.com> from line
'From: Alex Blewitt <alex.blewitt@gmail.com>'
Dry-OK. Log says:
Sendmail: /usr/sbin/sendmail -i alex.blewitt@gmail.com
From: Alex Blewitt <alex.blewitt@gmail.com>
To:
Cc: Alex Blewitt <alex.blewitt@gmail.com>
Subject: [PATCH 1/3] Allow monitor/unintersting objects to be null
Date: Wed,  6 May 2009 22:26:05 +0100
Message-Id: <1241645167-8427-1-git-send-email-alex.blewitt@gmail.com>
X-Mailer: git-send-email 1.6.2.2
Result: OK
(mbox) Adding cc: Alex Blewitt <alex.blewitt@gmail.com> from line
'From: Alex Blewitt <alex.blewitt@gmail.com>'
Dry-OK. Log says:
Sendmail: /usr/sbin/sendmail -i alex.blewitt@gmail.com
From: Alex Blewitt <alex.blewitt@gmail.com>
To:
Cc: Alex Blewitt <alex.blewitt@gmail.com>
Subject: [PATCH 2/3] Use NullProgressMonitor.INSTANCE and indent for loop
Date: Wed,  6 May 2009 22:26:06 +0100
Message-Id: <1241645167-8427-2-git-send-email-alex.blewitt@gmail.com>
X-Mailer: git-send-email 1.6.2.2
In-Reply-To: <1241645167-8427-1-git-send-email-alex.blewitt@gmail.com>
References: <1241645167-8427-1-git-send-email-alex.blewitt@gmail.com>
Result: OK
(mbox) Adding cc: Alex Blewitt <alex.blewitt@gmail.com> from line
'From: Alex Blewitt <alex.blewitt@gmail.com>'
Dry-OK. Log says:
Sendmail: /usr/sbin/sendmail -i alex.blewitt@gmail.com
From: Alex Blewitt <alex.blewitt@gmail.com>
To:
Cc: Alex Blewitt <alex.blewitt@gmail.com>
Subject: [PATCH 3/3] Don't allow others to instantiate NullProgressMonitor
Date: Wed,  6 May 2009 22:26:07 +0100
Message-Id: <1241645167-8427-3-git-send-email-alex.blewitt@gmail.com>
X-Mailer: git-send-email 1.6.2.2
In-Reply-To: <1241645167-8427-2-git-send-email-alex.blewitt@gmail.com>
References: <1241645167-8427-1-git-send-email-alex.blewitt@gmail.com>
 <1241645167-8427-2-git-send-email-alex.blewitt@gmail.com>
Result: OK

← back to recent threads