UPD
master
master
进行一些更改,就像在分支上一样
(例如在分支上添加'a'行并删除'b',然后编辑'c'
在master
执行相同的操作:添加行'a',删除'b'但编辑'd')master
所以,现在,在master
,我们有:
$ git diff ForkPoint..master:HEAD
@@@patch@@@
new line 'a'
removed line 'b'
edited line 'd'
在分支上,我们有:
$ git diff ForkPoint..branch:HEAD
@@@patch@@@
new line 'a'
removed line 'b'
edited line 'c'
现在我想查看分支上的所有更改,但master
中已有的更改除外。
$ git checkout master; git diff branch:HEAD
@@@patch@@@
edited line 'd'
edited line 'c'
但是,我不希望在master
ForkPoint..master:HEAD
@@@patch@@@
edited line 'c'
上看到其他更改
预期
git cherry -v branch:HEAD
我需要像
这样的东西 @Transactional(propagation = Propagation.REQUIRED)
public class ConstitutionFichiersDonneesWriter extends ClassifierCompositeItemWriter<RequeteBO> implements
Classifier<RequeteBO, ItemWriter<? super RequeteBO>>, ItemStream {
private static final Logger LOGGER = LoggerFactory.getLogger(ConstitutionFichiersDonneesWriter.class);
private Map<String, FlatFileItemWriter<RequeteBO>> writers = new HashMap<String, FlatFileItemWriter<RequeteBO>>();
// table_modif fichier
private Map<String, RequeteBO> tableModifs = new HashMap<String, RequeteBO>();
private ExecutionContext executionContext;
private SimpleJdbcTemplate simpleJdbcTemplate;
private String folderOrc;
public ConstitutionFichiersDonneesWriter() {
setClassifier(this);
}
@Autowired
public void setDataSource(final DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
}
@Autowired
public void setResource(final String resource) {
this.folderOrc = resource;
}
@Override
public ItemWriter<? super RequeteBO> classify(final RequeteBO classifiable) {
String fileName = classifiable.getFolderName() + "/" + classifiable.getFileName();
if (!writers.containsKey(fileName)) {
FlatFileItemWriter<RequeteBO> writer = createWriter(fileName);
writer.open(executionContext);
writers.put(fileName, writer);
tableModifs.put(fileName, classifiable);
}
return writers.get(fileName);
}
private FlatFileItemWriter<RequeteBO> createWriter(final String tableName) {
FlatFileItemWriter<RequeteBO> writer = new FlatFileItemWriter<RequeteBO>();
writer.setResource(new FileSystemResource(this.folderOrc + tableName + ".sql"));
DelimitedLineAggregator<RequeteBO> delLineAgg = new DelimitedLineAggregator<RequeteBO>();
delLineAgg.setDelimiter(",");
BeanWrapperFieldExtractor<RequeteBO> fieldExtractor = new BeanWrapperFieldExtractor<RequeteBO>();
fieldExtractor.setNames(new String[] { "query" });
delLineAgg.setFieldExtractor(fieldExtractor);
writer.setLineAggregator(delLineAgg);
return writer;
}
@Override
public void open(final ExecutionContext executionContext) throws ItemStreamException {
this.executionContext = executionContext;
}
@Override
public void update(final ExecutionContext executionContext) throws ItemStreamException {
for (FlatFileItemWriter<RequeteBO> writer : writers.values()) {
writer.update(executionContext);
}
}
@Override
public void close() throws ItemStreamException {
for (FlatFileItemWriter<RequeteBO> writer : writers.values()) {
writer.close();
}
Date dateCourante = new Date();
List<Object[]> listeNamedParametersTableModif = new ArrayList<Object[]>();
for (RequeteBO requeteBO : this.tableModifs.values()) {
listeNamedParametersTableModif.add(new Object[] { dateCourante, dateCourante, requeteBO.getType(),
requeteBO.getFileName() + ".sql", EnumStatutModif.FICHIER_CREE.getCode(), requeteBO.getRevisionDossier(),
requeteBO.getDossier(), requeteBO.getFkTableFonc() });
}
// Pour chaque fichier, un enregistrement est créé dans la table
// table_modif.
LOGGER.debug("Création des enregistrements table_modif pour chaque fichier créé");
String insertTableModif = "INSERT INTO technique.table_modif (dt_creation, dt_maj, type, nom, statut, fk_revision_dossier, dossier, fk_table_fonc) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
this.simpleJdbcTemplate.batchUpdate(insertTableModif, listeNamedParametersTableModif);
}
但是这个检查整个提交。我需要线路。
答案 0 :(得分:0)
Git可能无法为您提供完成此任务的选项,但您可以通过以下方式完成此任务:
git diff master..mybranch | grep -v "^-[^-]"
这将删除以单个&#34; - &#34;开头的所有行,即master
但不存在于mybranch
中的任何行。
您可能需要根据您的环境采用此方法。