You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Sean Busbey (JIRA)" <ji...@apache.org> on 2014/09/11 00:26:35 UTC
[jira] [Commented] (HBASE-11937) Update patch submission guidelines
to stop using --no-prefix
[ https://issues.apache.org/jira/browse/HBASE-11937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14129251#comment-14129251 ]
Sean Busbey commented on HBASE-11937:
-------------------------------------
A committer should first see if the patch applies cleanly to master. This works the same regardless of which git command created the patch.
{noformat}
$> git fetch origin
$> git checkout master
$> git rebase origin/master
$> git checkout example-checking-HBASE-11891
$> git apply --check /some/path/to/patches/HBASE-11891.patch
{noformat}
No output means things are fine. Failures look like this:
{noformat}
$ git apply --check /some/path/to/patches/HBASE-11891.old.patch
error: patch failed: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterStatusListener.java:34
error: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterStatusListener.java: patch does not apply
error: patch failed: hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseInterfaceAudience.java:29
error: hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseInterfaceAudience.java: patch does not apply
error: patch failed: hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodec.java:25
error: hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodec.java: patch does not apply
error: patch failed: hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodecWithTags.java:25
error: hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodecWithTags.java: patch does not apply
....
{noformat}
If the patch doesn't apply, the contributor should updated it for the current master.
A committer can tell if the patch was made with git format-patch (rather than git diff) if it begins with a header that looks like an email message:
{noformat}
>From b7893a4e07cbff333d48065dad9810f9f03cf159 Mon Sep 17 00:00:00 2001
From: Sean Busbey <bu...@apache.org>
Date: Wed, 3 Sep 2014 23:23:16 -0500
Subject: [PATCH] HBASE-11891 Introduce an HBaseInterfaceAudience level to
denote class names that appear in configs.
---
{noformat}
If the patch was made with format patch, then they should use {{git am}} to apply.
{noformat}
$ git am /some/path/to/format-patch/patches/HBASE-11891.patch
Applying: HBASE-11891 Introduce an HBaseInterfaceAudience level to denote class names that appear in configs.
{noformat}
This will place a commit in the current local branch, which you can interact with normally via git commands.
If the patch was mad with git diff, then they should use {{git apply}} to apply.
{noformat}
$ git apply /some/path/to/diff/patches/HBASE-11891.patch
{noformat}
No output means things worked fine. This approach won't add a commit; instead all changes will be on the current working directory.
{noformat}
$ git status
# On branch example-checking-HBASE-11891
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterStatusListener.java
# modified: hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseInterfaceAudience.java
# modified: hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodec.java
....
{noformat}
For patches created with {{git diff}} a committer can also use the {{patch}} command to apply changes locally.
{noformat}
$ patch -p1 < /some/path/to/diff/patches/HBASE-11891.patch
patching file hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterStatusListener.java
patching file hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseInterfaceAudience.java
patching file hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodec.java
patching file hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodecWithTags.java
...
{noformat}
This should give you a working directory that is the same as the one created by {{git apply}}.
At this point you can interact with the local changes as you would with local modifications you made.
> Update patch submission guidelines to stop using --no-prefix
> ------------------------------------------------------------
>
> Key: HBASE-11937
> URL: https://issues.apache.org/jira/browse/HBASE-11937
> Project: HBase
> Issue Type: Improvement
> Components: documentation
> Reporter: Sean Busbey
> Priority: Minor
>
> Right now the submission guidelines include the use of --no-prefix in the Methods to Create Patches section:
> {quote}
> Git
> git format-patch is preferred because it preserves commit messages. Use git squash first, to combine smaller commits into a single larger one.
> * git format-patch --no-prefix origin/master --stdout > HBASE-XXXX.patch
> * git diff --no-prefix origin/master > HBASE-XXXX.patch
> {quote}
> The use of --no-prefix means that users of {{git apply}} and {{git am}} have to know to specify {{-p0}} and (which strips 0 levels of prefix). Both of those tools default to stripping the 1 level of prefix git makes by default.
> The guide for HBase committers section on reviewing doesn't give any suggestions on how to apply patches from contributors. It should probably give examples for using {{git am}} and {{git apply}}.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)