java - Issue in conflict in stash -


this scenario

  1. i did change on file a.

  2. i created new file b

  3. do stash

  4. do change in file a.

  5. do commit

  6. do use stash

  7. call status -> 1 file in conflit didn't file untracked b.

it occured in scenario without conflict working ok

i using jgit org.eclipse.jgit,3.4.2.201412180340-r

code stash

@override protected boolean handlepost(requestinfo requestinfo) throws servletexception {  jsonobject requestpayload = requestinfo.getjsonrequest(); httpservletrequest request = requestinfo.request; httpservletresponse response = requestinfo.response; repository db = requestinfo.db;  string indexmessage = requestpayload.optstring(gitconstants.key_stash_index_message); string workingdirectorymessage = requestpayload.optstring(gitconstants.key_stash_working_directory_message); boolean includeuntracked = requestpayload.optboolean(gitconstants.key_stash_include_untracked, false);  try {      git git = new git(db);     stashcreatecommand stashcreate = git.stashcreate();     stashcreate.setperson(new personident(db));     stashcreate.setincludeuntracked(includeuntracked);      if (!indexmessage.isempty())         stashcreate.setindexmessage(indexmessage);      if (!workingdirectorymessage.isempty())         stashcreate.setworkingdirectorymessage(workingdirectorymessage);      stashcreate.call();     return true;  } catch (exception ex) {     string msg = "an error occured stash command.";     return statushandler.handlerequest(request, response, new serverstatus(istatus.error, httpservletresponse.sc_internal_server_error, msg, ex)); } 

}

code use stash

@override     protected boolean handleput(requestinfo requestinfo) throws servletexception {          jsonobject requestpayload = requestinfo.getjsonrequest();         httpservletrequest request = requestinfo.request;         httpservletresponse response = requestinfo.response;         repository db = requestinfo.db;          /* gitapi/stash/<stashrev>/file/(...) */         string stashrev = requestinfo.gitsegment;          boolean applyindex = requestpayload.optboolean(gitconstants.key_stash_apply_index, true);         boolean applyuntracked = requestpayload.optboolean(gitconstants.key_stash_apply_untracked, true);          try {              git git = new git(db);              /* check empty stash */             if (isstashempty(git)) {                 string msg = "failed apply stashed changes due empty stash.";                 return statushandler.handlerequest(request, response, new serverstatus(istatus.warning, httpservletresponse.sc_bad_request, msg, null));             }              stashapplycommand applycommand = new stashapplycommand(db);              if (stashrev != null) {                  stashref stashref = getstashref(git, stashrev);                 if (stashref == null) {                     string msg = nls.bind("invalid stash reference {0}.", stashrev);                     return statushandler.handlerequest(request, response, new serverstatus(istatus.error, httpservletresponse.sc_bad_request, msg, null));                 }                  applycommand.setstashref(stashref.getstringref());                 applycommand.setapplyuntracked(applyuntracked);                 applycommand.setapplyindex(applyindex);                 applycommand.call();              } else {                  /* git stash pop */                 applycommand.setapplyuntracked(applyuntracked);                 applycommand.setapplyindex(applyindex);                 applycommand.call();                 stashdropcommand dropcommand = git.stashdrop();                 dropcommand.setall(false);                 dropcommand.call();              }              return true;          } catch (gitapiexception gitex) {             string msg = "an error occured stash command issue conflict.";             return statushandler.handlerequest(request, response, new serverstatus(istatus.warning, httpservletresponse.sc_conflict, msg, gitex));         } catch (exception ex) {             string msg = "an error occured stash command.";             return statushandler.handlerequest(request, response, new serverstatus(istatus.error, httpservletresponse.sc_internal_server_error, msg, ex));         }     } 

code commit

@override protected boolean handlepost(requestinfo requestinfo) throws servletexception {     string gitsegment = requestinfo.gitsegment;     httpservletrequest request = requestinfo.request;     httpservletresponse response = requestinfo.response;     repository db = requestinfo.db;     string pattern = requestinfo.relativepath;     jsonobject requestobject = requestinfo.getjsonrequest();     try {         string committomerge = requestobject.optstring(gitconstants.key_merge, null);         if (committomerge != null) {             boolean squash = requestobject.optboolean(gitconstants.key_squash, false);             return merge(request, response, db, committomerge, squash);         }          string committorebase = requestobject.optstring(gitconstants.key_rebase, null);         string rebaseoperation = requestobject.optstring(gitconstants.key_operation, null);         if (committorebase != null) {             return rebase(request, response, db, committorebase, rebaseoperation);         }          string committocherrypick = requestobject.optstring(gitconstants.key_cherry_pick, null);         if (committocherrypick != null) {             return cherrypick(request, response, db, committocherrypick);         }          string committorevert = requestobject.optstring(gitconstants.key_revert, null);         if (committorevert != null) {             return revert(request, response, db, committorevert);         }          string newcommit = requestobject.optstring(gitconstants.key_commit_new, null);         if (newcommit != null)             return identifynewcommitresource(request, response, db, newcommit);          string reviewreqlogin = requestobject.optstring(gitconstants.key_review_req_notify_login);         if (reviewreqlogin != null && reviewreqlogin.length() != 0) {             string reviewrequrl = requestobject.optstring(gitconstants.key_review_req_url);             string reviewreqcommit = requestobject.optstring(gitconstants.key_review_req_commit);             string reviewreqauthorname = requestobject.optstring(gitconstants.key_review_req_author_name);             string reviewmessage = requestobject.optstring(gitconstants.key_review_req_message);             return sendnotification(request, response, db, reviewreqlogin, reviewreqcommit, reviewrequrl, reviewreqauthorname, reviewmessage);         }          objectid refid = db.resolve(gitsegment);         if (refid == null || !constants.head.equals(gitsegment)) {             string msg = nls.bind("commit failed. ref must head , {0}", gitsegment);             return statushandler.handlerequest(request, response, new serverstatus(istatus.error, httpservletresponse.sc_bad_request, msg, null));         }          string message = requestobject.optstring(gitconstants.key_commit_message, null);         if (message == null || message.isempty()) {             return statushandler.handlerequest(request, response, new serverstatus(istatus.error, httpservletresponse.sc_bad_request,                     "missing commit message.", null));         }          git git = new git(db);         commitcommand cc = git.commit();         config config = git.getrepository().getconfig();          boolean amend = boolean.parseboolean(requestobject.optstring(gitconstants.key_commit_amend, null));         boolean insertchangeid = config.getboolean(configconstants.config_gerrit_section, configconstants.config_key_createchangeid, false)                 || boolean.parseboolean(requestobject.optstring(gitconstants.key_change_id, null));          string committername = requestobject.optstring(gitconstants.key_committer_name, null);         string committeremail = requestobject.optstring(gitconstants.key_committer_email, null);         string authorname = requestobject.optstring(gitconstants.key_author_name, null);         string authoremail = requestobject.optstring(gitconstants.key_author_email, null);          // workaround of bug in jgit causes invalid         // support of null values of author/committer name/email, see bug         // 352984         personident defpersonident = new personident(db);         if (committername == null)             committername = defpersonident.getname();         if (committeremail == null)             committeremail = defpersonident.getemailaddress();         if (authorname == null)             authorname = committername;         if (authoremail == null)             authoremail = committeremail;         cc.setcommitter(committername, committeremail);         cc.setauthor(authorname, authoremail);         if (insertchangeid)             cc.setinsertchangeid(true);          // support committing path: "git commit -o path"         if (!pattern.isempty()) {             cc.setonly(pattern);         }          try {             // "git commit [--amend] -m '{message}' [-a|{path}]"             revcommit lastcommit = cc.setamend(amend).setmessage(message).call();              uri clonelocation = basetocloneconverter.getclonelocation(geturi(request), basetocloneconverter.commit_refrange);             commit commit = new commit(clonelocation, db, lastcommit, pattern);             jsonobject result = commit.tojson();             orionservlet.writejsonresponse(request, response, result, jsonuriunqualificationstrategy.all_no_git);             return true;         } catch (gitapiexception e) {             return statushandler.handlerequest(request, response, new serverstatus(istatus.error, httpservletresponse.sc_bad_request,                     "an error occurred when committing.", e));         } catch (unmergedpathexception e) {             return statushandler.handlerequest(request, response, new serverstatus(istatus.error, httpservletresponse.sc_internal_server_error,                     "an internal error occurred when committing.", e));         }     } catch (exception e) {         return statushandler.handlerequest(request, response, new serverstatus(istatus.error, httpservletresponse.sc_internal_server_error,                 "an error occurred when requesting commit information.", e));     } }  code status     @override     protected boolean handleget(requestinfo requestinfo) throws servletexception {          httpservletrequest request = requestinfo.request;         httpservletresponse response = requestinfo.response;         repository db = requestinfo.db;          int page = request.getparameter("page") != null ? new integer(request.getparameter("page")).intvalue() : 1; //$non-nls-1$ //$non-nls-2$         int pagesize = request.getparameter("pagesize") != null ? new integer(request.getparameter("pagesize")).intvalue() : page_size; //$non-nls-1$ //$non-nls-2$         string messagefilter = request.getparameter("filter"); //$non-nls-1$         try {              uri baselocation = geturi(request);             uri clonelocation = basetocloneconverter.getclonelocation(baselocation, basetocloneconverter.commit);              git git = new git(db);             stashlistcommand stashlist = git.stashlist();             collection<revcommit> stashedrefscollection = stashlist.call();              stashpage stashpage = new stashpage(clonelocation, db, stashedrefscollection, page, pagesize, messagefilter);             orionservlet.writejsonresponse(request, response, stashpage.tojson());             return true;          } catch (exception ex) {             string msg = "an error occured stash command.";             return statushandler.handlerequest(request, response, new serverstatus(istatus.error, httpservletresponse.sc_internal_server_error, msg, ex));         }     } 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -